`--disallow-untyped-calls` reports errors in untyped functions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Using --disallow-untyped-calls and --check-untyped-defs results in errors about calling untyped functions in a typed context, even when calling from an untyped function.
To Reproduce
Test case:
[case testDisallowUntypedCallsFromUntypedFunction]
# flags: --disallow-untyped-calls --check-untyped-defs
def f(x):
pass
def g(y):
f(y)
Expected Behavior
Either:
- the documentation and the error message should be updated to specify that
--disallow-untyped-callsdisallows all calls to untyped functions, regardless of whether the current function has type annotations, or - the above code shouldn't produce any errors
Actual Behavior
The call to f in the above example produces the error "Call to untyped function "f" in typed context".
Your Environment
See https://mypy-play.net/?mypy=latest&python=3.10&flags=check-untyped-defs%2Cdisallow-untyped-calls&gist=3350fe27968b29dabc5ef1e207d008ce to reproduce.
This came up in #12901 (specifically the mypy_primer diff had an error here)
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 with the test case named testDisallowUntypedCallsFromUntypedFunction and reproduce it with --disallow-untyped-calls and --check-untyped-defs. Trace how the call to f is classified inside g, then resolve whether the intended fix is updated documentation and wording or changed behavior so the test no longer errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100