Created
April 21, 2026 17:57
-
-
Save sharkdp/4fe630b6d6b737bc8172eab1b63d2f53 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
| def f(): | |
| f.some_attribute = 1 # all type checkers error on this | |
| # but how do users type something like `typing.final`, which adds an attribute to a function? | |
| from typing import Protocol, Callable | |
| class HasAttribute(Protocol): | |
| some_attribute: int | |
| def adds_attribute[C: Callable](f: C) -> C: | |
| f.some_attribute = 1 # type: ignore | |
| return f | |
| @adds_attribute | |
| def g(): ... |
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 = ["pulumi"] | |
| [tool.ty] | |
| [tool.ty.rules] | |
| undefined-reveal = "ignore" | |
| [tool.pyright] | |
| reportWildcardImportFromLibrary = false | |
| reportSelfClsParameterName = false | |
| reportUnusedExpression = false | |
| [tool.mypy] | |
| color_output = true | |
| pretty = true | |
| check_untyped_defs = true | |
| [tool.pyrefly] | |
| [tool.pyrefly.errors] | |
| unimported-directive = false | |
| [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