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
{{ message }}
Repository navigation
Should it be possible to subclass TextIO without implementing all abstract methods? #112
If we want to allow people to create subclasses without implementing <long list of methods>, why are they included in the abstract class? Could we make some of them mix-in methods instead?
If we want to call any of <long list of methods>, and we have an instance of TextIO, should we be prepared to handle an AttributeError?
I like the way the I/O system handles seekability in this regard (i.e. there's a seekable() method which returns True or False) -- could other features provide a similar API?
What if we broke TextIO apart into a bunch of smaller abstract classes which do one thing each (e.g. TextReadable, TextWriteable, TextSeekable)?
Currently, the python2 stubs for cStringIO are forced to lie because read/write methods are not split into separate base classes. Doubtless there are many other cases, both in python2 and python3.
Activity
NYKevin commentedon May 28, 2015
Some (disjointed) thoughts:
register()?<long list of methods>, why are they included in the abstract class? Could we make some of them mix-in methods instead?<long list of methods>, and we have an instance ofTextIO, should we be prepared to handle anAttributeError?seekable()method which returns True or False) -- could other features provide a similar API?TextReadable,TextWriteable,TextSeekable)?o11c commentedon Oct 20, 2015
Currently, the python2 stubs for
cStringIOare forced to lie because read/write methods are not split into separate base classes. Doubtless there are many other cases, both in python2 and python3.Suggest retitling to
IO[AnyStr].srittau commentedon Nov 4, 2021
I believe this issue is obsolete by now, due to protocols and the suggestion to use protocols for I/O argument types.