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

mypy dislikes next() on file objects #2111

Closed
jhagerer opened this issue Sep 8, 2016 · 1 comment
Closed

mypy dislikes next() on file objects #2111

jhagerer opened this issue Sep 8, 2016 · 1 comment

Comments

@jhagerer
Copy link

jhagerer commented Sep 8, 2016

When mypy analyzes the following code:

filename = 'some.txt'
with open(filename) as fh:
    c = cast(TextIOWrapper, fh)
    next(c)  # skip line

it yields the following error:
error: No overload variant of "next" matches argument types [io.TextIOWrapper]

Since TextIOWrapper implements the next() method (which is even autocompleted by PyCharm IDE), I would not expect this error to be thrown.

@jhagerer
Copy link
Author

jhagerer commented Sep 8, 2016

For the moment I make a workaround like this:

fh = cast(TextIOWrapper, open(filename))
fh.__next__()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants