Inconsistent dataclass declaration
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
The dataclass decorator in the typeshed package has an inconsistency in its overloads. Specifically, when cls is passed explicitly as None, it is unclear whether additional arguments (e.g., init, repr, etc.) should be allowed or not. The current implementation allows passing cls=None alongside additional arguments, but this usage is not explicitly documented or validated.
Expected Behavior
The overloads should clearly define and document the behavior of cls=None when additional arguments are provided:
If allowed, the typing should reflect that explicitly.
If not allowed, the implementation should prevent or warn against such usage.
Current Behavior
Passing cls=None with arguments like kw_only=True is allowed, but this behavior is not described in the overloads. For example:
decorator = dataclass(None, kw_only=True)
@decorator
class MyClass:
x: int
The above works but is ambiguous in terms of type checking and intended usage.
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 locating the dataclass decorator overloads in the typeshed package and compare them with the shown dataclass(None, kw_only=True) example. Resolve whether cls=None with additional arguments is supported, then make the overloads and documentation consistently express that decision. Done means the behavior is unambiguous to type checkers and users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100