`--untyped-calls-exclude` should consider inheritance
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
I think it would make sense to use --untyped-calls-exclude based on the defining class of an untyped function. However, that is not currently possible.
Related: https://github.com/python/mypy/issues/16653
To Reproduce
class Super:
def draw(self):
...
class Class(Super):
...
Class().draw()
Expected Behavior
mypy --no-incremental --disallow-untyped-calls --untyped-calls-exclude=bug.Super bug.py
gives no error.
Actual Behavior
bug.py:8: error: Call to untyped function "draw" in typed context [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)
I can use --untyped-calls-exclude=bug.Class to work around this, but when inheriting from a class from an untyped library, it makes more sense to exclude the actual culprit and avoid false negatives (namely, other functions correctly typed in Class).
Your Environment
- Mypy version used: 1.7.1.
- Mypy command-line flags: see above
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.12.1
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 reproducing the command in the issue with bug.py, focusing on how --disallow-untyped-calls and --untyped-calls-exclude handle the inherited draw method. Trace the untyped-call check and method resolution, then verify that excluding bug.Super suppresses this error without broadly excluding correctly typed methods in Class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100