Skip to content

TypeVar alias in stub does not work #1430

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
rchen152 opened this issue May 24, 2023 · 0 comments
Closed

TypeVar alias in stub does not work #1430

rchen152 opened this issue May 24, 2023 · 0 comments
Labels
bug cat: stubs and 3p type stubs and third-party types

Comments

@rchen152
Copy link
Contributor

Pytype cannot parse a stub that aliases typing.TypeVar to something else:

from typing import TypeVar as _TypeVar
T = _TypeVar('T')
def f(x: T) -> T: ...

An error like this is generated:

  [...]
  File "[...]/pytype/pytd/pytd.py", line 831, in LookupItemRecursive
    raise KeyError(item)
KeyError: TypeDeclUnit(name='typing', [...])

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  [...]
  File "[...]/pytype/load_pytd.py", line 266, in resolve_external_types
    raise BadDependencyError(str(e), name) from e
pytype.load_pytd.BadDependencyError: 'No TypeVar in module typing', referenced from 'foo'
@rchen152 rchen152 added bug cat: stubs and 3p type stubs and third-party types labels May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cat: stubs and 3p type stubs and third-party types
Projects
None yet
Development

No branches or pull requests

1 participant