Created
March 6, 2026 11:33
-
-
Save AlexWaygood/0685f09832604c2cb53928d004881454 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"version": 1, "file_mapping": {"main.py": "main.py", "pyproject.toml": "pyproject.toml"}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Any, overload, reveal_type | |
| class Invariant[KT, VT]: | |
| attr2: VT | |
| @overload | |
| def foo(self, other: Invariant[KT, VT]) -> Invariant[KT, VT]: ... | |
| @overload | |
| def foo[T1, T2](self, other: Invariant[T1, T2]) -> Invariant[KT | T1, VT | T2]: ... | |
| def foo(self, other): | |
| raise NotImplementedError | |
| def g(x: Invariant[int, int], y: Invariant[int, str], z: Invariant[int, Any]): | |
| reveal_type(x.foo(y)) # Invariant[int, int | str] | |
| reveal_type(x.foo(z)) # ty: Unknown | |
| # pycroscope: Any[multiple_overload_matches] | |
| # mypy, zuban: Invariant[Any, Any] | |
| # pyrefly, pyright: Invariant[int, int] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [project] | |
| name = "sandbox" | |
| version = "0.1.0" | |
| requires-python = ">=3.10" | |
| dependencies = [] | |
| [tool.zuban] | |
| pretty = true | |
| check_untyped_defs = true | |
| [tool.mypy] | |
| color_output = true | |
| pretty = true | |
| check_untyped_defs = true | |
| [tool.pyright] | |
| reportWildcardImportFromLibrary = false | |
| reportSelfClsParameterName = false | |
| reportUnusedExpression = false | |
| [tool.ty] | |
| [tool.ty.rules] | |
| undefined-reveal = "ignore" | |
| [tool.pycroscope] | |
| import_paths = ["."] | |
| [tool.pyrefly] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment