Skip to content

Name 'typing.io.IO' is not defined #4639

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

Closed
FichteFoll opened this issue May 1, 2016 · 7 comments
Closed

Name 'typing.io.IO' is not defined #4639

FichteFoll opened this issue May 1, 2016 · 7 comments

Comments

@FichteFoll
Copy link
Contributor

The Python 3.5 docs list a typing.io something ("wrapper namespace" according to docs, class according to interpreter), which you can access with IO to get an IO type, or for example TextIO. Using this in an interpreter works fine, but mypy complains about this.

>>> typing.io.IO[str]
typing.IO[str]
>>> typing.io.TextIO
typing.TextIO[str]
prettify.py:40: error: Name 'typing.io.IO' is not defined

I understand (now) that typing.IO is also possible, but the docs are very vague about that being a possibility, which is why I didn't even try it. Docs aside, since this works in the interpreter I think it should also work in mypy, which is why I'm reporting it.

@gvanrossum
Copy link
Member

gvanrossum commented May 1, 2016

Right, it's meant as a namespace, it seems mypy doesn't understand this
yet. Bug.

@gvanrossum
Copy link
Member

We added this to PEP 484 and typing.py in a relatively late stage, as a preferred way to separate support for specific modules from support for fundamentals (including containers). I guess mypy never implemented it. Maybe you can also submit a doc bug for Python 3.5?

@hauntsaninja hauntsaninja transferred this issue from python/mypy Oct 9, 2020
@gvanrossum
Copy link
Member

It's a passive-aggressive way of telling people that using typing.io.IO is deprecated. :-)

Seriously, we should add it, but I'd also like to deprecate it, at least in the docs.

@rohitkg98
Copy link
Contributor

How do we go around adding type aliases inside the io module.
I tried doing something like this:

class io:

    __all__ = ['IO', 'TextIO', 'BinaryIO']

    IO = Union[IO]
    TextIO = Union[TextIO]
    BinaryIO = Union[BinaryIO]

but this introduces cyclic definition error in mypy

Also, the Union is used as workaround for this

@JelleZijlstra
Copy link
Member

We should probably just give up on typing.io. It's never worked with mypy and I haven't seen a lot of demand for it.

@gvanrossum
Copy link
Member

We should probably just give up on typing.io. It's never worked with mypy and I haven't seen a lot of demand for it.

Okay, let's close this then. Can someone file an issue with cpython to deprecate typing.io?

@rohitkg98
Copy link
Contributor

Created the issue to deprecate: https://bugs.python.org/issue42001

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

Successfully merging a pull request may close this issue.

4 participants