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

PyType cannot handle type annotations of TypeAliasType (it's treated as callable) #1775

Open
wyattscarpenter opened this issue Sep 19, 2024 · 1 comment

Comments

@wyattscarpenter
Copy link
Contributor

wyattscarpenter commented Sep 19, 2024

TypeAliasType is the type of what you get when you use the type keyword, eg:

type Point = tuple[float, float]

It is valid (or at least mypy and pyright allow you to) to pass the resultant type alias (Point in the example above) to functions, in which case it is supposed to have a type of TypeAliasType, However, annotating a function argument as TypeAliasType produces an error in PyType:

from typing import TypeAliasType

def f (t: TypeAliasType) -> None:
  pass

here is the error:

tat.py:3:1: error: in <module>: Invalid type annotation '<instance of Callable>'  [invalid-annotation]
  Not a type

def f (t: TypeAliasType) -> None:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  pass
~~~~~~

Pyright and mypy don't error on this code, as I've implied.

Possibly related issues:

#1475 (I guess Python 3.12 support is not truly complete until you can do this?)

#1295 (possibly similar decay-to-callable issue?)

@wyattscarpenter wyattscarpenter changed the title PyType cannot handle type annotations of TypeAliasType (treated as callable) PyType cannot handle type annotations of TypeAliasType (it's treated as callable) Sep 19, 2024
@frigus02
Copy link
Contributor

Yes, Python 3.12 is only supported with Python 3.11 syntax right now.

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