Support conditional definitions in dataclasses, etc.
Open
Nobody has claimed this yet.
feature
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
Support Python version and other checks that can be evaluated statically in bodies of dataclasses, named tuples, and other cases discussed in https://github.com/python/typing-council/issues/58.
Example that should work:
import sys
from typing import NamedTuple
class NT(NamedTuple):
x: int
if sys.version_info >= (3, 12):
y: str
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the example and the linked typing-council discussion, then inspect mypy's handling of dataclasses and NamedTuple definitions. Identify how statically evaluable Python-version checks are currently treated. Done means the example type-checks correctly and the agreed conditional-definition cases are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100