set[str].discard(str | None)
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
Consider the following:
names: set[str] = {"a", "b"}
name: str | None = None
names.discard(name)
It would be nice if this wasn't a type checker error. Unlike .remove(), the .discard() method does nothing if the item is not in the set, so I don't see a good reason to ban None values.
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 with the minimal Python reproduction in the issue and trace how the repository currently types set.discard. Compare that behavior with remove(), then verify that the requested None case is accepted without changing the set's declared element type; the issue's example provides the completion check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100