(🎁) Option to not report errors from stub bodies
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
test.py:
import foo
foo.foo("")
stubs/foo/init.pyi:
def foo(i: int) -> None:
1 + ""
mypy test.py
stubs/foo/__init__.pyi:2: error: Unsupported operand types for + ("int" and "str")
test.py:2: error: Argument 1 to "foo" has incompatible type "str"; expected "int"
Found 2 errors in 2 files (checked 1 source file)
In when I'm working with mypy I basically copy-paste the src of libraries into a stubs folder and gradually type them as needed, but it's a pain when I get errors on the bodies of functions like
stubs/x/y/z.pyi error: Call to untyped function "amongus" in typed context [no-untyped-call]
The bodies of stub functions shouldn't need to be typechecked imo and there should be an option to disable this.
I don't delete the bodies of the functions because that would be a lot of work, and it is kinda convinient that the impl and types are in the same place.
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
Use the test.py and stubs/foo/init.pyi reproducer and run mypy test.py. Trace how diagnostics from stub function bodies are produced, then verify an option suppresses those diagnostics while retaining the call-site argument error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100