Repository navigation
Introduce the "bare"/"explicitly typed" Final terminology - #2370
Conversation
|
|
||
| * A dataclass field may be annotated with ``Final[...]``. For example, ``x: | ||
| Final[int]`` in a dataclass body specifies a dataclass field ``x``, which | ||
| * A dataclass field may be annotated with an :term:`explicitly typed Final` |
There was a problem hiding this comment.
We may have to say what "bare Final" does in dataclasses. I discovered ty handles this buggily: astral-sh/ty#4766.
There are two cases:
- Bare Final with a default. The obvious interpretation is that that gives you a Final dataclass field with a literal type, which is coherent but kind of useless (you can only pass that one specific type).
- Bare Final without a default. Ty and pyrefly implement this like
Final[Any], which is sort of coherent but a little surprising to me; mypy disallows it; pyright interpretsFinalitself as a type which is definitely buggy.
There was a problem hiding this comment.
Oh yes, I failed to mention that: Bare Finals in dataclasses are a thing, but were not mentioned by the specs. I wanted to keep the status quo in this PR, because it's not about that. I think this should be a separate discussion.
Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
|
I'm not sure how the process for these more editorial changes is. Does is need sign-off from the whole council? |
There was a problem hiding this comment.
Since this is not a "substantive" change but rather a clarification of terminology I would argue that you can just merge it. Otherwise somebody of use would have asked you to open a post on discuss as described at https://github.com/python/typing-council#decisions
I think it's good to leave issues like this one open for a week to get enough eyes on it. But it's been open more than a week, so feel free to merge.
The main changes:
Finalspec:self.id: Finalwas moved to the semantics section where it fits better, since it's not a separate syntax.The rest of the changes use the new terms and link to the new glossary entries.
Closes: #2356