Created
May 27, 2026 15:43
-
-
Save AlexWaygood/17be90c733fd42744969a5ecd7214a78 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 NewType | |
| class Foo: ... | |
| FooNewType1 = NewType("FooNewType1", Foo) | |
| FooNewType2 = NewType("FooNewType2", Foo) | |
| foo = Foo() | |
| foo1 = FooNewType1(foo) | |
| foo2 = FooNewType2(foo) | |
| if foo1 is foo2: # evaluates to `True` at runtime | |
| reveal_type(foo1) # Never | |
| reveal_type(foo2) # Never | |
| BoolNewType = NewType("BoolNewType", bool) | |
| IntNewType = NewType("IntNewType", int) | |
| StrNewType = NewType("StrNewType", str) | |
| BytesNewType = NewType("BytesNewType", bytes) | |
| true = True # has type `Literal[True]` | |
| fourty_two = 42 # has type `Literal[42]` | |
| some_string = 'some_string' # has type `Literal["some_string"]` | |
| some_bytes = b'some_bytes' # has type `Literal[b"some_bytes"] | |
| if BoolNewType(true) is true: # evaluates to `True` at runtime | |
| reveal_type(true) # Never | |
| if IntNewType(fourty_two) is fourty_two: # evaluates to `True` at runtime | |
| reveal_type(fourty_two) # Never | |
| if StrNewType(some_string) is some_string: # evaluates to `True` at runtime | |
| reveal_type(some_string) # Never | |
| if BytesNewType(some_bytes) is some_bytes: # evaluates to `True` at runtime | |
| reveal_type(some_bytes) # Never |
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.ty] | |
| [tool.ty.rules] | |
| undefined-reveal = "ignore" | |
| [tool.pyright] | |
| reportWildcardImportFromLibrary = false | |
| reportSelfClsParameterName = false | |
| reportUnusedExpression = false | |
| [tool.pyrefly] | |
| [tool.pyrefly.errors] | |
| unimported-directive = false | |
| [tool.mypy] | |
| color_output = true | |
| pretty = true | |
| check_untyped_defs = true | |
| [tool.zuban] | |
| pretty = true | |
| check_untyped_defs = true | |
| [tool.pycroscope] | |
| import_paths = ["."] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment