Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ABC for .getvalue #86

Open
jayvdb opened this issue Sep 11, 2019 · 5 comments
Open

Create ABC for .getvalue #86

jayvdb opened this issue Sep 11, 2019 · 5 comments
Assignees
Labels
doc Changes/additions to the project documentation enhancement New feature or request
Milestone

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Sep 11, 2019

stdio_mgr expects getvalue to exist on BytesIO, and previously expected it to exist on StringIO, and the docs still refer to StringIO.getvalue, but there is no base/abstract type which defines this.

>>> import io
>>> io.BytesIO.__class__.__mro__
(<class 'type'>, <class 'object'>)
>>> issubclass(io.BytesIO, io.IOBase)
True
>>> io.StringIO.__class__.__mro__
(<class 'type'>, <class 'object'>)
>>> issubclass(io.StringIO, io.IOBase)
True

There is nothing in https://github.com/python/typing or title search on bpo

We should create our own temporary ABC for this, so we can hang features on it, add new ones (like _PersistedFileIO as a BytesIO with a fileno()), and raise issues upstream about it. This is also 'needed' for bytes support (#36) if we use strict type checking (#60)

e.g. #80 is a feature that depends on .getvalue and little else.

@jayvdb jayvdb added enhancement New feature or request doc Changes/additions to the project documentation labels Sep 11, 2019
@jayvdb jayvdb changed the title Create ABC for Create ABC for .getvalue Sep 11, 2019
@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 11, 2019

i.e. we need this .getvalue to exist on the TextIOWrapper instances, but it isnt defined as existing there.

@bskinn
Copy link
Owner

bskinn commented Sep 11, 2019

Agreed - we want this here, even if it's not found to be worth porting upstream into stdlib.

@jayvdb jayvdb self-assigned this Sep 12, 2019
@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 12, 2019

any naming suggestions?

@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 12, 2019

AbstractIOValue?

@bskinn
Copy link
Owner

bskinn commented Sep 12, 2019

Thinking out loud---there will probably be more than just .getvalue() going into this, but it's hard to anticipate what it'll be at this point.

So, the name should be more general than just AbstractGetValueIO.

  • AbstractIntrospectingIO - might be a good balance?

  • AbstractReportingIO? - doesn't do reporting automatically, but sort of describes what it'd be doing

  • AbstractFancyIO? - Not very accurately descriptive, but shorter!

  • AbstractMockedIO? - Accurate to what we're doing with the subclasses, but possibly too general?

@bskinn bskinn added this to the v2.0 milestone Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Changes/additions to the project documentation enhancement New feature or request
Development

No branches or pull requests

2 participants