microsoft / microsoft/vscode-mypy
Mypy "no-untyped-def" error highlights entire function, visually noisy and masking other errors
- Dominant language
- Python
- Stars
- 150
- Forks
- 39
- Avg merge
- 21h 45m
- Merged PRs (30d)
- 8
Description
## Diagnostic Data
- Python version (& distribution if applicable, e.g., Anaconda): python 3.14.2
- Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): venv (uv)
- Operating system (and version): fedora 43
- Version of tool extension you are using: 2025.2.0
## Behaviour
### Expected Behavior
When mypy reports "no-untyped-def", it should be visually discernible from other errors in a function.
### Actual Behavior
When mypy reports "no-untyped-def", the entire function is highlighted red. This way, the red underline masks other errors and adds a ton of visual noise to the screen. In particular, for files without any type annotations, but where I want the errors on because we'll be adding types eventually, it makes it very difficult to visually parse the file when everything is underlined red.
## Reproduction Steps:
Example python file -
```
def foo(a: str):
if a == True: return 1
return a + b + c
```
And in pyproject.toml, I have configured `tool.mypy.strict = true`.
This results in highlighting like so.
Compare to this example where the function return type is added and it's much easier to see the other errors in the function and much less noisy.
Similar example with more code -
It seems like this error should only cause it to highlight the function declaration, not all source code under the function.
Contributor guide
Research direction
Reproduce the behavior with the Python example and the strict settings in pyproject.toml, then trace how the extension handles mypy's no-untyped-def diagnostic. The repository files and tests are not identified in the issue; done means that diagnostic no longer highlights the function body while the other errors remain visually distinguishable.
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
- 45/100