Please just change something. Weird combination of dead code and inferred None
Open
Nobody has claimed this yet.
feature
topic-configuration
topic-reachability
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
foo = None
def bar() -> str:
global foo
if foo is not None:
print("Hello")
else:
foo = "bar"
return "lol"
This program type-checks, even though it's obviously wrong. It's not a bug, it's a feature:
- Inferred type of
fooisNone, even thoughOptional[str]was intended. - Because
foohas typeNone, theif foo is not None:part is eliminated as dead code, and therefore the missing return isn't detected. - After setting
foo = "bar",reveal_type(foo)showsstr. Perhaps the assignment should be an error?
Pitch
A friend submitted a PR like this and thought it was fine.
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
The payload names no files, tests, or entry points. Start by running the provided snippet through mypy and reviewing how inferred None, global reassignment, unreachable branches, and missing returns are handled. A maintainer decision on the intended semantics and regression coverage is needed before implementation can be scoped.
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
- Needs clarification
- Newbie friendliness
- 25/100