Disallow formatting None into f-string
Open
Nobody has claimed this yet.
feature
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
Code like this should be an error, if some option is turned on:
foo: str | None = None
print(f"blah blah {foo}")
Pitch
When reviewing code like this, I manually check whether foo can be None. For example, you don't want a user interface to display There are None active users, or Do you want to delete 'None'?.
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 from the issue's f-string example and inspect how mypy currently checks values interpolated into f-strings. Determine how the proposed opt-in behavior should report a possibly-None value and what tests are needed to cover accepted and rejected cases.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100