You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From python/mypy#338 -- not sure if this is still a good idea, but I'm moving all stubs-related mypy issues here if I'm not sure I can close them.
Currently the typing.IO[AnyStr] ABC only has operations that are valid for both binary and text files. This is sometimes awkward. Potentially add the entire file object interface to IO[AnyStr] so that IO[Any] supports both the text and binary file interfaces. We might then be able to get rid of TextIO and BinaryIO classes. This would simplify the programming model at the cost of some type checking precision. However, some code that is currently not statically typable would be (more) typable, so there might actually even be a net benefit in static typing precision.
The text was updated successfully, but these errors were encountered:
See also discussion in python/mypy#1472. We could perhaps use something like the constraint-based approach proposed there to enforce that only the correct set of methods are available based on the value of a type variable. So binary-only methods would only be available on IO[bytes] and IO[Any], and text-only methods would only be available on IO[str] and IO[Any]. By having something like this, we'd get the precise type checking of the current approach with a simpler class hierarchy.
(I don't know whether this would be practical to implement, but it might well be.)
typing.IO currently has a long list of methods, and the issue has no concrete list of methods that should be added to IO. I don't think there's anything concrete to do here now; let's reopen if there's concrete code samples that could be helped by a change in the IO stubs.
From python/mypy#338 -- not sure if this is still a good idea, but I'm moving all stubs-related mypy issues here if I'm not sure I can close them.
The text was updated successfully, but these errors were encountered: