Skip to content

Mypy "no-untyped-def" error highlights entire function, visually noisy and masking other errors #429

@ion201

Description

@ion201

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.

Image

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.

Image

Similar example with more code -

Image

It seems like this error should only cause it to highlight the function declaration, not all source code under the function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bugtriage-needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions