Motivation behind not being able to get IO's content, and IO-wrapped interfacing with unwrapped (normal) code
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Empieza por la documentación y los puntos de entrada relacionados con IO mencionados en el issue, especialmente unsafe_perform_io y la distinción entre el código Python envuelto y el código Python estándar. Aclara la justificación para ocultar el contenido de IO y documenta el límite compatible entre las operaciones envueltas en IO y el código Python ordinario.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi! Question(s) on IO.
I am trying to write a little wrapper for some stateful operation (imagine I have to do IO from/to a file), and I found out that IO containers are designed to hide their content. It's impossible to get the value of, say, a successful read result (nothing like IOSuccess.unwrap()), unless one uses unsafe_perform_io.
What is the rationale behind this design? I am asking because I am not familiar with writing typed functional code, and I could not find a motivation in the documentation for why it shouldn't be possible to get the raw content of an IO container.
Second question related to interface between IO-wrapped code and normal "unsafe" code:
Let's say I am writing code A where want to mark and wrap all IO operations. Now, code A has to interface with standard python code B. What choices do I have to make them talk?
Do I have to unwrap all my operations with unsafe_perform_io, in case I want to do something simple like getting a string from my wrapped code? Do I have to rewrite code B by making it all safe and IO-wrapped, so that they can communicate with no "unsafe" bridge between them?
It seems that in such scenario I would end up with code pieces that are of "different colors" - using the usual async-vs-sync metaphore of incompatible red and blue code -, and I would be forced to make everything of the same color.
(Here "red code" = "python code written in railway style" and "blue code" = "standard procedural python code").
- Lenguaje dominante
- Python
- Estrellas
- 4.4k
- Forks
- 154
- Merge medio
- 3 h 5 min
- PR fusionados (30 d)
- 22
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dry-python/returns
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
dry-python/returns#2394 · 1 reacción ·
-
Composing 0-argument functions Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
dry-python/returns#2365 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
dry-python/returns#2355 · 1 comentario ·
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
dry-python/returns#2295 · 4 comentarios · 1 reacción ·
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
dry-python/returns#2253 · 2 comentarios ·
Todos los issues de dry-python/returns
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
huggingface/Repo2RLEnv#163 · 1 comentario ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NousResearch/hermes-agent#121143 ·