Warning/Error for unassigned expressions/return values
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
Adding a warning or error if an expression is not assigned would encourage callers to handle return types and pick up on changes to APIs.
Pitch
Imagine you have this api:
def fleeb_the_foo() -> None:
print("fleebing")
def main() -> None:
fleeb_the_foo()
Then you change it later:
def fleeb_the_foo() -> Bool:
print("I failed to fleeb!")
return False
def main() -> None:
fleeb_the_foo() # <<--- a warning or error here!
If you don't want to handle the warning/error:
def fleeb_the_foo() -> Bool:
print("I failed to fleeb!")
return False
def main() -> None:
_ = fleeb_the_foo() # error is suppressed
This is already implemented to some degree with pylint for unassigned expressions with [expression-not-assigned]
str(42) == "42" # [expression-not-assigned]
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 comparing the proposed behavior with pylint's expression-not-assigned check, which is linked in the issue. Clarify which unassigned return values should produce diagnostics and how explicit _ = suppression should work. Done means the behavior and diagnostic rules are defined well enough to implement and test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100