Comments (3)
I think that this would be really uncommon for a non-block statement to support docstrings this way.
Right now __doc__
is not even assignable on TypeAliasType
instances:
>>> type A = int
>>> A.__doc__
'Type alias.\n\nType aliases are created through the type statement::\n\n type Alias = int\n\nIn this example, Alias and int will be treated equivalently by static\ntype checkers.\n\nAt runtime, Alias is an instance of TypeAliasType. The __name__\nattribute holds the name of the type alias. The value of the type alias\nis stored in the __value__ attribute. It is evaluated lazily, so the\nvalue is computed only if the attribute is accessed.\n\nType aliases can also be generic::\n\n type ListOrSet[T] = list[T] | set[T]\n\nIn this case, the type parameters of the alias are stored in the\n__type_params__ attribute.\n\nSee PEP 695 for more information.\n'
>>> A.__doc__ = 'My info'
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
A.__doc__ = 'My info'
^^^^^^^^^
AttributeError: 'typing.TypeAliasType' object attribute '__doc__' is read-only
from cpython.
I don't think it's unreasonable to want to add a docstring to a type alias, but I agree with @sobolevn that this specific proposal would be pretty unprecedented. So we'd need to have a discussion over exactly how we'd want to add the feature. In short, I agree with @nineteendo — this would need to first be discussed on Discourse to hash out design details of the feature in a community forum, before opening a GitHub issue
from cpython.
Major feature proposals should generally be discussed on Discourse before opening a GitHub issue.
from cpython.
Related Issues (20)
- Simplify Windows write I/O around consoles on Windows 8+
- LoongArch to Tier 3 HOT 2
- Use *.pyi stub files as source for the inspect.signature() HOT 6
- Thread sanitizer tests failing in GitHub actions HOT 5
- test_pyrepl: test_inspect_keeps_globals_from_inspected_file() fails on s390x Fedora 3.x HOT 1
- Code object creation (const interning) can mutate tuples
- Missing audit events for `python -i` and `python -m asyncio` HOT 1
- The mod(modulo) calculation with `complex` values gets the wrong error message saying 'complex' and 'float' instead of 'complex' and 'complex' HOT 2
- test_makefile_test_folders test failures on python 3.12
- Add option to functools.update_wrapper()/@wraps to copy the coroutine flag
- Improve and reorganise ``pyspecific``
- test_pyrepl: test_inspect_keeps_globals_from_inspected_* are very flaky
- `statistics.mode` fails for unhashable data HOT 8
- Make Memory-Related Tests Less Fragile
- Env Variable to Auto-Name and Recognize __pycache__ As .__pycache__
- csv module: Missing test case for an invalid quoting value
- `test_pyrepl` is taking 1 hour on refleaks buildbots HOT 3
- Using custom OpenSSL version 3.x when compiling Python 3.x - fails HOT 1
- Introduce configure --disable-openssf-guide or --enable-openssf-guide HOT 17
- Fully implement PEP 706: Change default filter for TarFile.extract() and extractall() to 'data'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.