Skip to content

Mypy extension doesn't show errors when project dir contains symlink #391

@czhang1216

Description

@czhang1216

Diagnostic Data

  • Python version (& distribution if applicable, e.g., Anaconda): cpython3.13
  • Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): venv
  • Operating system (and version): windows 11 -> Remote into RHEL 8
  • Version of tool extension you are using: 2025.2.0
  • vscode 1.108.1

Behaviour

Expected Behavior

Suppose I have a project under /home/myusername/my_project, where /home/myusername is a symlink to /home11/myusername (due to NFS setup), I'm expecting mypy extension just work.

Actual Behavior

mypy errors don't show up in the editor, nor the "Problems" panel tab.

Reproduction Steps:

In linux

mkdir A
ln -s A B
cd B
python3.13 -m venv .venv
.venv/bin/pip install mypy
code .

Create a a.py file with type errors, but the errors are not shown.

a: int = 3
a = "hello"

Logs:

Click here for detailed logs

Notice the flipflop between A and B in the logs:

2026-01-21 14:16:16.167 [info] CWD Server: /XXX/A

2026-01-21 14:16:16.184 [info] Settings used to run Server:
[
    {
        "cwd": "/XXX/B",
        "workspace": "file:///XXX/B",
        "args": [],
        "severity": {
            "error": "Error",
            "note": "Information"
        },
        "path": [],
        "ignorePatterns": [],
        "interpreter": [
            "/XXX/B/.venv/bin/python"
        ],
        "importStrategy": "fromEnvironment",
        "showNotifications": "off",
        "extraPaths": [],
        "reportingScope": "file",
        "preferDaemon": false,
        "daemonStatusFile": ""
    }
]

2026-01-21 14:16:16.188 [info] Global settings:
{
    "cwd": "${workspaceFolder}",
    "workspace": "/REDACTED",
    "args": [],
    "severity": {
        "error": "Error",
        "note": "Information"
    },
    "path": [],
    "ignorePatterns": [],
    "interpreter": [],
    "importStrategy": "fromEnvironment",
    "showNotifications": "off",
    "extraPaths": [],
    "reportingScope": "file",
    "preferDaemon": false,
    "daemonStatusFile": ""
}

...

2026-01-21 14:16:16.214 [info] /XXX/B/.venv/bin/python -m mypy --version
2026-01-21 14:16:16.287 [info] CWD Server: /XXX/A
2026-01-21 14:16:16.327 [info] 
mypy 1.19.1 (compiled: yes)


2026-01-21 14:16:16.329 [info] Version info for linter running for /XXX/A:
mypy 1.19.1 (compiled: yes)

...

2026-01-21 14:16:16.407 [info] [Trace - 2:16:16 PM] Received notification 'window/logMessage'.
2026-01-21 14:16:16.407 [info] Params: {
    "type": 4,
    "message": "/XXX/B/.venv/bin/python -m mypy --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-error-end /XXX/A/a.py"
}


2026-01-21 14:16:16.407 [info] /XXX/B/.venv/bin/python -m mypy --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-error-end /XXX/A/a.py
2026-01-21 14:16:16.408 [info] [Trace - 2:16:16 PM] Received notification 'window/logMessage'.
2026-01-21 14:16:16.408 [info] Params: {
    "type": 4,
    "message": "CWD Server: /XXX/A"
}


2026-01-21 14:16:16.408 [info] CWD Server: /XXX/A
2026-01-21 14:16:17.452 [info] [Trace - 2:16:17 PM] Received notification 'window/logMessage'.
2026-01-21 14:16:17.453 [info] Params: {
    "type": 4,
    "message": "file:///XXX/B/a.py :\r\n/XXX/A/a.py:2:5:2:11: error: Incompatible types in assignment (expression has type \"str\", variable has type \"int\")  [assignment]\n"
}


2026-01-21 14:16:17.453 [info] file:///XXX/B/a.py :
/XXX/A/a.py:2:5:2:11: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]

2026-01-21 14:16:17.453 [info] [Trace - 2:16:17 PM] Received notification 'window/logMessage'.
2026-01-21 14:16:17.453 [info] Params: {
    "type": 4,
    "message": "file:///XXX/B/a.py :\r\n/XXX/A/a.py:2:5:2:11: error: Incompatible types in assignment (expression has type \"str\", variable has type \"int\")  [assignment]\n"
}


2026-01-21 14:16:17.453 [info] file:///XXX/B/a.py :
/XXX/A/a.py:2:5:2:11: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]

2026-01-21 14:16:17.454 [info] [Trace - 2:16:17 PM] Received notification 'textDocument/publishDiagnostics'.
2026-01-21 14:16:17.454 [info] Params: {
    "uri": "file:///XXX/B/a.py",
    "diagnostics": []
}

Outcome When Attempting Debugging Steps:

Extra Details

It seems, in mypy itself, --show-absolute-path, used by the extension, resolves symlinks.
AFAICT vscode also resolves symlinks sometimes. So these behaviors complicates things.

/XXX/B $ rm -r .mypy_cache  # mypy saves paths in cache, disregarding --show/hide-absolute-path
/XXX/B $ mypy --show-absolute-path a.py

/XXXA/a.py:2: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]

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