Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# be pinned to a specific version to make failure reproducible.
mypy==2.3.0
pyrefly==1.3.0.dev1
pyright==1.1.411
pyright==1.1.413
ty==0.0.59

# Libraries used by our various scripts.
Expand Down
4 changes: 3 additions & 1 deletion stdlib/@tests/test_cases/check_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ def foo(self) -> None:
if sys.version_info >= (3, 11):
union_type = int | list[_T]

# pyright and mypy infer different types here
# ideally this would be `_SpecialForm` (Union)
assert_type(union_type | Literal[1], types.UnionType | Any)
assert_type(union_type | Literal[1], types.UnionType | Any) # pyright: ignore[reportAssertTypeFailure]
# assert_type(union_type | Literal[1], types.UnionType | type[Literal[1]]) # this is what pyright infers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type[Literal[1]] is a nonsense type -- it's quite unclear what it would/should mean. I don't think it should be valid to parameterize type with Literal[...]. So we could possibly report this as a bug to pyright.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that (but I'm not to familiar with "meta types"). Would you report it? I think a report by you would be clearer than me only half-understanding what I write. I would then just update the comment with a link to the issue.

# Both mypy and pyright special-case this operation,
# but in different ways, so we just check that no error is emitted:
_ = union_type[int]
Loading