"typing.BinaryIO" missing "readinto" method
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug report
Bug description:
typeing.BinaryIO is completely missing the readinto method. All binary mode return values of open support the readinto method, and the lack of it on the BinaryIO type makes type-hinting difficult when using this method. One could try to use io.RawIOBase | io.BufferedIOBase but this looses the fact that the result of open has a name property. This has been brought up in python/typing#659 and python/typeshed#2166.
Furthmore, the write method in BinaryIO is declared to only be compatible with Union[bytes, bytearray] when it should be anything that satisfies collections.abc.Buffer.
I propose that BinaryIO should look something more like:
class BinaryIO(IO[bytes]):
"""Typed version of the return of open() in binary mode."""
__slots__ = ()
@abstractmethod
def readinto(self, b: collections.abc.Buffer) -> int:
pass
@abstractmethod
def write(self, s: collections.abc.Buffer) -> int:
pass
@abstractmethod
def __enter__(self) -> 'BinaryIO':
pass
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
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.
Línea de trabajo
Comience con la definición de typing.BinaryIO y compárela con los valores de retorno de open() en modo binario, centrándose en las firmas propuestas de readinto y write compatibles con Buffer. Verifique que BinaryIO siga exponiendo la propiedad name y que el comportamiento actualizado de typing esté cubierto por las pruebas existentes pertinentes; el issue no especifica ningún archivo ni prueba concretos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- developer-experience
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100