| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
| class _MISSING_TYPE(enum.Enum): | ||
| MISSING = enum.auto() | ||
| if sys.version_info >= (3, 15): | ||
| MISSING: Final[sentinel] |
There was a problem hiding this comment.
hm this might regress functionality, can't we already do MISSING = sentinel("MISSING")?
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks, @JelleZijlstra, that makes perfect sense. This was my first contribution, inspired by the EuroPython sprints, where the dataclasses stubs were listed as candidates for a fix.
It looks however like the correct fix is currently blocked by a tooling constraint: typeshed pins mypy to 2.3.0, which does not yet support sentinel values as types. That work is pending in python/mypy#21647.
Should we close this PR for now and revisit it once the mypy PR is merged and typeshed updates its pin, or would you prefer to keep it open as a draft until then?
Sorry, something went wrong.
There was a problem hiding this comment.
@caseneuve can you check if python/mypy#21647 results in no errors for your changes? MISSING: Final[sentinel] might just not work, but I'm curious about MISSING = sentinel("MISSING").
Sorry, something went wrong.
| default_factory: _DefaultFactory[_T] | Literal[_MISSING_TYPE.MISSING] | ||
|
|
||
| if sys.version_info >= (3, 15): | ||
| default: _T | sentinel |
There was a problem hiding this comment.
This is worse than before, we should hint the specific sentinel not the sentinel type.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
In Python 3.15, dataclasses.MISSING and dataclasses.KW_ONLY were changed from custom class instances (_MISSING_TYPE, _KW_ONLY_TYPE) to builtins.sentinel objects (see: python/cpython#149086) and _MISSING_TYPE no longer exists at runtime.
This PR: