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

Pyright hangs on some recursive aliases #9497

Closed
kyle-query opened this issue Nov 22, 2024 · 2 comments
Closed

Pyright hangs on some recursive aliases #9497

kyle-query opened this issue Nov 22, 2024 · 2 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@kyle-query
Copy link

kyle-query commented Nov 22, 2024

Describe the bug

Pyright hangs in certain cases involving recursive type aliases.

Code or Screenshots

from typing import TypeVar, Generic

U = TypeVar("U")
T = TypeVar("T")

class A(Generic[T]):
    pass

class B(Generic[T]):
    pass

class Tagged(Generic[T]):
    pass

NoTag = A["Either[U]"] | B["Either[U]"]
Either = NoTag[U] | Tagged[NoTag[U]]

### If this is moved to a separate file, there is no problem
Problem = Either[U]

Here's my pyrightconfig.json:

{
  "pythonVersion": "3.11",
  "typeCheckingMode": "strict",
}

Changing this to pythonVersion 3.12 and modifying the source accordingly fixes the problem:

type NoTag[U] = A[Either[U]] | B[Either[U]]
type Either[U] = NoTag[U] | Tagged[NoTag[U]]
type Problem[U] = Either[U]

With Python 3.11, using the : TypeAlias annotation does not fix the problem.

VS Code extension or command-line

$ ./node_modules/.bin/pyright --version
pyright 1.1.389

This issue also occurs in pyright 1.1.385.

@kyle-query kyle-query added the bug Something isn't working label Nov 22, 2024
@erictraut
Copy link
Collaborator

Thanks for the bug report. I'm able to repro the problem, and I'll investigate further.

erictraut added a commit that referenced this issue Nov 29, 2024
erictraut added a commit that referenced this issue Nov 29, 2024
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Nov 29, 2024
@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.390.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants