The spec for enums describes what counts as an enum member and naming restrictions for members.
The spec for NamedTuple lacks these details. I propose we add the following to the typing spec:
- NamedTuple field names can’t start with
_, unless the names were assigned usingrename=True(otherwise, it’s a runtime error) - field names starting with
_are treated the same as illegal identifiers with regards torename=True - methods and un-annotated variables in a NamedTuple defined with the class syntax are not fields and don’t get included in things like the generated
__new__, unpacking, etc.
The proposed changes, examples, and associated conformance tests are added in Clarify namedtuple member rules by yangdanny97 · Pull Request #1979 · python/typing · GitHub
Please comment here or on the PR if you have any thoughts/feedback