Git Product home page Git Product logo

vscode-mypy's Introduction

Mypy extension for Visual Studio Code

A Visual Studio Code extension with support for the Mypy type checker. This extension ships with mypy=1.11.1.

Note: The minimum version of Mypy this extension supports is 1.0.0. If you have any issues with Mypy, please report it to this issue tracker as this extension is just a wrapper around Mypy.

This extension supports all actively supported versions of the Python language (i.e., Python >= 3.8).

For more information on Mypy, see https://www.mypy-lang.org/

Usage and Features

The Mypy extension provides a series of features to help your productivity while working with Python code in Visual Studio Code. Check out the Settings section for more details on how to customize the extension.

  • Integrated type checking: Once this extension is installed in Visual Studio Code, Mypy will be automatically executed when you open a Python file, reporting any errors or warnings in the "Problems" window.
  • Customizable Mypy version: By default, this extension uses the version of Mypy that is shipped with the extension. However, you can configure it to use a different binary installed in your environment through the mypy-type-checker.importStrategy setting, or set it to a custom Mypy executable through the mypy-type-checker.path settings.
  • Workspace-wide type checking: By default, this extension will only report errors and warnings for files open in the editor. However, you can configure it to report errors and warnings for the entire workspace through the mypy-type-checker.reportingScope setting.
  • Mono repo support: If you are working with a mono repo, you can configure the extension offer type checking for Python files in subfolders of the workspace root folder by setting the mypy-type-checker.cwd setting to ${fileDirname}. You can also set it to ignore/skip type checking for certain files or folder paths by specifying a glob pattern to the mypy-type-checker.ignorePatterns setting.
  • Customizable linting rules: You can customize the severity of specific Mypy error codes through the mypy-type-checker.severity setting.
  • Mypy Daemon support: This extension supports the Mypy daemon (dmypy) for faster type checking when the reporting scope is set to the entire workspace. To enable it, set the mypy-type-checker.preferDaemon setting to true.

Disabling Mypy

You can skip type checking with Mypy for specific files or directories by setting the mypy-type-checker.ignorePatterns setting.

If you wish to disable Mypy for your entire workspace or globally, you can disable this extension in Visual Studio Code.

Settings

There are several settings you can configure to customize the behavior of this extension.

Settings Default Description
mypy-type-checker.args [] Arguments passed to Mypy to enable type checking on Python files. Each argument should be provided as a separate string in the array.
Example:
"mypy-type-checker.args" = ["--config-file=<file>"]
mypy-type-checker.cwd ${workspaceFolder} Sets the current working directory used to lint Python files with Mypy. By default, it uses the root directory of the workspace ${workspaceFolder}. You can set it to ${fileDirname} to use the parent folder of the file being linted as the working directory for Mypy.
mypy-type-checker.severity { "error": "Error", "note": "Information" } Mapping of Mypy's message types to VS Code's diagnostic severity levels as displayed in the Problems window. You can also use it to override specific Mypy error codes.
For example: { "error": "Error", "note": "Information", "name-defined": "Warning" }
mypy-type-checker.path [] Path or command to be used by the extension to type check Python files with Mypy. Accepts an array of a single or multiple strings. If passing a command, each argument should be provided as a separate string in the array. If set to ["mypy"], it will use the version of Mypy available in the PATH environment variable. Note: Using this option may slowdown type checking.
Examples:
- ["~/global_env/mypy"]
- ["conda", "run", "-n", "lint_env", "python", "-m", "mypy"]
mypy-type-checker.interpreter [] Path to a Python executable or a command that will be used to launch the Mypy server and any subprocess. Accepts an array of a single or multiple strings. When set to [], the extension will use the path to the selected Python interpreter. If passing a command, each argument should be provided as a separate string in the array.
mypy-type-checker.importStrategy useBundled Defines which Mypy binary to be used to type check Python files. When set to useBundled, the extension will use the Mypy binary that is shipped with the extension. When set to fromEnvironment, the extension will attempt to use the Mypy binary and all dependencies that are available in the currently selected environment. Note: If the extension can't find a valid Mypy binary in the selected environment, it will fallback to using the Mypy binary that is shipped with the extension. Note: The mypy-type-checker.path setting takes precedence and overrides the behavior of mypy-type-checker.importStrategy.
mypy-type-checker.showNotifications off Controls when notifications are shown by this extension. Accepted values are onError, onWarning, always and off.
mypy-type-checker.reportingScope file (experimental) Controls the scope of Mypy's problem reporting. If set to file, Mypy will limit its problem reporting to the files currently open in the editor. If set to workspace, Mypy will extend its problem reporting to include all files within the workspace.
mypy-type-checker.preferDaemon true (experimental) Whether the Mypy daemon (dmypy) will take precedence over mypy for type checking. Note: if mypy-type-checker.reportingScope is set to workspace, enabling the Mypy daemon will offer a faster type checking experience. This setting will be overridden if mypy-type-checker.path is set.
mypy-type-checker.ignorePatterns [] Configure glob patterns as supported by the fnmatch Python library to exclude files or folders from being type checked by Mypy.

The following variables are supported for substitution in the mypy-type-checker.args, mypy-type-checker.cwd, mypy-type-checker.path, mypy-type-checker.interpreter and mypy-type-checker.ignorePatterns settings:

  • ${workspaceFolder}
  • ${workspaceFolder:FolderName}
  • ${userHome}
  • ${env:EnvVarName}

The mypy-type-checker.path setting also supports the ${interpreter} variable as one of the entries of the array. This variable is subtituted based on the value of the mypy-type-checker.interpreter setting.

Commands

Command Description
Mypy: Restart Server Force re-start the linter server.

Logging

From the Command Palette (View > Command Palette ...), run the Developer: Set Log Level... command. Select Mypy Type Checker from the Extension logs group. Then select the log level you want to set.

Alternatively, you can set the mypy-type-checker.trace.server setting to verbose to get more detailed logs from the Mypy server. This can be helpful when filing bug reports.

To open the logs, click on the language status icon ({}) on the bottom right of the Status bar, next to the Python language mode. Locate the Mypy Type Checker entry and select Open logs.

Troubleshooting

In this section, you will find some common issues you might encounter and how to resolve them. If you are experiencing any issues that are not covered here, please file an issue.

  • If the mypy-type-checker.importStrategy setting is set to fromEnvironment but Mypy is not found in the selected environment, this extension will fallback to using the Mypy binary that is shipped with the extension. However, if there are dependencies installed in the environment, those dependencies will be used along with the shipped Mypy binary. This can lead to problems if the dependencies are not compatible with the shipped Mypy binary.

    To resolve this issue, you can:

    • Set the mypy-type-checker.importStrategy setting to useBundled and the mypy-type-checker.path setting to point to the custom binary of Mypy you want to use; or
    • Install Mypy in the selected environment.
  • If you have the reporting scope set to workspace and notice a slowdown in type checking, you can try enabling the Mypy daemon (dmypy) by setting the mypy-type-checker.preferDaemon setting to true.

vscode-mypy's People

Contributors

antar-ghuman avatar avasam avatar connorads avatar danparizher avatar dependabot[bot] avatar detachhead avatar eleanorjboyd avatar hamirmahal avatar insilications avatar jammf avatar jyothirmaikottu avatar karthiknadig avatar lszomoru avatar luabud avatar meghprkh avatar microsoftopensource avatar mutantpenguin avatar peterjclaw avatar posita avatar privet-kitty avatar samskiter avatar srilasya02 avatar vidhanio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-mypy's Issues

Should not use `--follow-imports=skip`

This extension improves on the default behaviour of the main Python extension's handling of mypy in terms of the options it passes, however it appears to silently pass --follow-imports=skip. This causes all imports to be replaced by Any, in turn substantially limiting the usefulness of the type checking by causing both:

  • spurious errors when used in combination with warn_return_any (possibly other cases too), and
  • true errors to be missed, since any types imported (even from within the same project) are considered as Any and thus fully compatible with any other type

cannot find module or stub on all nonstandard packages when using pipenv

This may be user error, or may be more generalized than pipenv. I recently switched to using the mypy extension from using mypy within pylance. For every import for this project that isn't part of the standard library, mypy is producing a variation of the following error:

Cannot find implementation or library stub for module named "numpy.typing"

the python interpreter from within the virtual environment is active within vscode, and I'm getting lints like normal from pylance

Extension reports a large number of non-existant errors

Hello,

I started using the extension today and it is spamming my Problems pane with sometimes up to 2K+ errors which just don't exist. I don't get this behaviour when using the standard out of the box mypy cmdline.

Extension version: 2023.0.0
Extension mypy version: 1.4.1

See for example this screenshot:
image

Same output from mypy 1.4.1 cmdline:
image

My mypy.ini file for this project:

[mypy]
ignore_missing_imports=True
show_column_numbers=True
files=curve_patching

# be strict (taken from psf/black's mypy.ini)
disallow_untyped_calls=True
warn_return_any=True
strict_optional=True
warn_no_return=True
warn_redundant_casts=True
warn_unused_ignores=True
disallow_any_generics=True

Here's another example with another module generating 1K+ errors:
image

You can see on the above example that when I go to the line for the first error there is no mention/redefinition of the __path__ variable so the mypy extension is reporting something that doesnt exist?

Output from the Extension for the 2nd example (notice the amount of time the extension used to complete the mypy command...):
image

Apologies for the redactions and not being able to share the code because it is proprietary.

MyPy should receive the python interpreter used in the project

Environment data

  • VS Code version: 1.44.2
  • Extension version (available under the Extensions sidebar): 2020.4.76186
  • OS and version: macOS Catalina 10.15.4 (19E287)
  • Python version: 3.8.2
  • Type of virtual environment used: venv
  • Relevant/affected Python packages and their versions: mypy 0.770
  • Jedi or Language Server?: Jedi
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

When running mypy, it should receive --python-executable with the path to the active python interpreter if one is set.

Actual behaviour

When mypy runs, it lints with Python interpreter available to it, and not the one selected as interpreter in VSCode, and since --ignore-missing-imports is passed to mypy by default, it can be common that types are not correctly resolved, and errors are just being muted.

Steps to reproduce:

  1. Install MyPy globally (or with pipx)
  2. Create a virtual environment and open the project with VSCode
    python3 -m venv .venv
  3. Enable MyPy linting "python.linting.mypyEnabled": true and "python.linting.mypyPath": "/path/to/bin/mypy"
  4. Set the Python interpreter to the one in the virtual environment "python.pythonPath": ".venv/bin/python"
  5. Install some library that has custom types (I use boto3-stubs) .venv/bin/pip install boto3-stubs
  6. Create a file with:
    from mypy_boto3 import boto3_session
    session: boto3_session.Session = 123
  7. MyPy will not report any errors

Now, to fix that problem:

  1. Add --python-executable to the list of arguments passed to MyPy:
    "python.linting.mypyArgs": [
      "--ignore-missing-imports",
      "--follow-imports=silent",
      "--show-column-numbers",
      "--python-executable=.venv/bin/python3"
    ]
  2. MyPy will now report a type error: Incompatible types in assignment (expression has type "int", variable has type "Session")

I set this as a bug and not a feature request because VSCode knows what python interpreter the user wants to use, as it is a setting that the user can change. It would make sense that the interpreter is used when it affects the behaviour of other tools.

"Cannot find config file" in `mypy-type-checker.args`

I'm migrating our mypy config from the Python extension to this one, but running into an issue when specifying a --config-file. Here's my config:

        "python.linting.mypyEnabled": false,
        "mypy-type-checker.path": [
            "/usr/bin/mypy"
        ],
        "mypy-type-checker.args": [
            "--exclude=install/",
            "--config-file=/depot/mypy.ini"
        ],

And here's the error I'm getting in the Output tab:

2023-07-07 12:34:57.132 [info] /usr/bin/mypy --no-color-output --no-error-summary --show-column-numbers --show-error-code --no-pretty --exclude=install/ --config-file=/depot/mypy.ini --show-error-end /depot/path/to/src.py
2023-07-07 12:34:57.133 [info] [Trace - 12:34:57 PM] Received notification 'window/logMessage'.
2023-07-07 12:34:57.133 [info] CWD Server: /depot
2023-07-07 12:34:57.242 [info] [Trace - 12:34:57 PM] Received notification 'window/logMessage'.
2023-07-07 12:34:57.242 [info] usage: mypy [-h] [-v] [-V] [more options; see below]
            [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: Cannot find config file '/depot/mypy.ini'

I've tried various flavors of the same flag but none of them seem to work.

  • ["--config-file=/depot/mypy.ini"] (what the docs recommend)
  • ["--config-file=mypy.ini"] (assuming it was doing relative paths from the CWD and not absolute?)
  • ["--config-file", "/depot/mypy.ini"] (space separated maybe?)
  • ["--config-file", "mypy.ini"]

Add docs show an example of what the extension is expected to do once installed

I've installed the Mypy Type Checker extension, v2023.2.0.

I've created a file example.py:

def add(a: int, b: int) -> int:
    return a + b


add("2", 2)

number: int = "1"

and if I run python -m mypy -m example on the command line I get the following reported type errors:

user@a18a8366e3cc:/app/src/$ python -m mypy -m example
example.py:5: error: Argument 1 to "add" has incompatible type "str"; expected "int"  [arg-type]
example.py:7: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 2 errors in 1 file (checked 1 source file)

When I open the same python file in VS Code, nothing happens.

But then I'm not sure what I'm supposed to expect to happen ๐Ÿ˜…. I presume I should see the type errors highlighted in the editor, and listed in the PROBLEMS tab of the panel.

In the VS Code panel, if I go to the OUTPUT tab and select "Mypy Type Checker" I can see that the Mypy extension is watching the file. For example, I see this in the output console when I save the file:

2023-08-13 17:55:08.220 [info] /usr/local/bin/python -m mypy.dmypy --status-file /tmp/.vscode.dmypy_status/status-d4e33441-2339-403d-af67-c1b1e622ca39.json run -- --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-code --no-pretty --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty --show-error-end /app/src/madeline/example.py
2023-08-13 17:55:08.221 [info] CWD Server: /app
2023-08-13 17:55:08.372 [info] dmypy: follow-imports=silent not supported

2023-08-13 17:55:08.372 [info] file:///app/src/example.py :

But none of the expected type errors from the command line experiment are reported anywhere in VS Code.
There is no error highlighting in the editor window, and the PROBLEMS tab of the panel is empty also.

It would be nice to see the README updated to provide an example of expected behaviour.

Consider changing default Mypy Arguments setting to avoid spurious errors when used with warn_unused_ignores

Environment data

  • VS Code version: 1.46.1
  • Extension version (available under the Extensions sidebar): 2020.6.90262

Expected behaviour

I generally expect that my editor will give the same linter experience as running a linter directly on the command line.

Actual behaviour

For the case of warn_unused_ignores in combination with a type: ignore comment on an import line, running mypy through VSCode differs from the command line experience and thus from what any scripted runs (including CI) would output. This results from the vscode-python extension passing non-default arguments to mypy which override behaviours the user may have configured in their project.

Steps to reproduce:

# setup.cfg
[mypy]
warn_unused_ignores = True
# demo.py
import asttokens  # type: ignore

print(asttokens)
pip install asttokens==2.0.4 mypy

I'm using asttokens here, but I've seen this with other libraries too (for example parso and jedi). The common theme is that it is a library which doesn't have type annotations.

Command line run:

$ mypy demo.py 
demo.py:9: error: Function is missing a type annotation
Success: no issues found in 1 source file

VSCode Output tab output:

demo.py:1: error: unused 'type: ignore' comment
Found 1 error in 1 file (checked 1 source file)

I had initially assumed that this was a bug in vscode-python and it was only while reviewing the mypy setting to check I didn't have any changes I should include in the bug report that I spotted the non-default arguments which vscode-python passes to mypy.

I can definitely see why the chosen options were set -- to reduce the noise from mypy for new users who may not have configured mypy themselves, however this leads to a non-obvious difference between mypy in the editor and mypy on the command line.

I can see that it may be somewhat reasonable for an editor to have false negatives (or hide errors) relative to the command line, however the issue here is that these options create false positives -- errors in the editor which it is not clear how to resolve and which do not reproduce elsewhere. This leads to a reduction in trust that the editor and/or mypy is reporting the right things.

[FEATURE REQUEST]ย Option to install third party stub packages to be used with the embedded mypy interpreter

Hello,

Apologies if this has been answered already. I tried a quick search of issues and PRs but got no hits. How is this extension suggesting to handle third-party stub packages? I am for example getting a Library stubs not installed for "yaml" error in many of my files which clogs up my problems window. I am aware that I can adjust the settings to not display these types of errors but I would like to use third-party stub packages if they are available. Installing types-PyYAML in my local .venv does not work since the extension is using the packaged mypy interpreter. I could also tell the extension to use a custom mypy interpreter from my .venv with the third-party packages installed but it would be a nice feature to be able to embed these with the packaged mypy interpreter so that I could use the same setup across several projects.

`warn-unused-ignores` doesn't work

image

settings

{
  "mypy-type-checker.importStrategy": "useBundled",
  "mypy-type-checker.args": [
    "--show-column-numbers",
    "--no-pretty",
    "--hide-error-context",
    "--warn-unused-ignores"
  ]
}

logs

2023-05-02 11:22:45.838 [info] [Trace - 11:22:45 AM] Received notification 'window/logMessage'.
2023-05-02 11:22:45.838 [info] file:///c%3A/Users/user/project/sandpit/asdf.py :
sandpit\asdf.py:1:12:1:14: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
sandpit\asdf.py:3: error: Unused "type: ignore" comment

2023-05-02 11:22:45.839 [info] [Trace - 11:22:45 AM] Received notification 'textDocument/publishDiagnostics'.

Flaky (works once, but never again) out-of-the-box

Steps to reproduce (ref posita/dyce@790a067):

% uname -prism
Linux 6.4.6-76060406-generic x86_64 x86_64 x86_64
% which python
python not found
% which python3
/usr/bin/python3
% python3 --version
Python 3.10.12
% git clone https://github.com/posita/dyce.git
Cloning into 'dyce'...
remote: Enumerating objects: 7093, done.
remote: Counting objects: 100% (2781/2781), done.
remote: Compressing objects: 100% (1320/1320), done.
remote: Total 7093 (delta 1481), reused 2565 (delta 1375), pack-reused 4312
Receiving objects: 100% (7093/7093), 39.06 MiB | 2.97 MiB/s, done.
Resolving deltas: 100% (4528/4528), done.
% cd dyce
% git checkout 790a067
% which code
/usr/bin/code
% code .

Once open:

  1. Command Palette -> Output: Focus on Output View
  2. Go to File... -> evaluation.py
  3. Command Palette -> Output: Show Output Channels... -> Mypy Type Checker

Without further input, this will (eventually) lead to the following problems:

Missing return statement
[{
	"resource": "/home/<username>/<path>/dyce/dyce/evaluation.py",
	"owner": "_generated_diagnostic_collection_name_#3",
	"code": {
		"value": "empty-body",
		"target": {
			"$mid": 1,
			"path": "/en/latest/_refs.html",
			"scheme": "https",
			"authority": "mypy.readthedocs.io",
			"fragment": "code-empty-body"
		}
	},
	"severity": 8,
	"message": "Missing return statement",
	"source": "Mypy",
	"startLineNumber": 87,
	"startColumn": 5,
	"endLineNumber": 93,
	"endColumn": 12
}]

Add some text to the comment at the top of the opened evaluation.py file and save the file. Note that Mypy is run but no longer detects the error. Remove your edits and save. Mypy runs again, but still doesn't detect the error. You can only get the error back by reloading the window.

Error message persists after fix/save

mypy: 1.5.0
extension: v2023.3.12231010
vscode: Version: 1.82.0-insider Commit: 2d9cc42045edf3458acbddf3d645bba993f82696

If I have a type error:

a: int = "asd"

Error:
Incompatible types in assignment (expression has type "str", variable has type "int")

And then I delete or fix the line with the error and save, mypy runs and produces no error, but the error diagnostic persists in vs-code:

image

You can see that the blank line has the tilde with the type error still. This persists until something triggers another error. It looks like the "no error" output isn't being parsed correctly or an update isn't being sent to vs-code.

Originally raised by @cpnielsen in #115

Mypy only updates outputs when restarting server.

Using pre-release version.

This issue seems different to #119, no outputs are ever updated unless the server is rebooted (from what I can see). Changing or re-opening a file dosen't cause mypy to re-check the file. Example video below showing the following steps:

  1. Introducing an error
  2. Saving the file
  3. Waiting for mypy
  4. No mypy changes
  5. Restarting the mypy server
  6. Mypy changes
mypymp4.mp4

My extension settings:

image

When editing and changing files, I get the following outputs:

2023-08-27 15:10:37.728 [info] [Trace - 3:10:37 PM] Sending notification 'textDocument/didChange'.
2023-08-27 15:10:38.726 [info] [Trace - 3:10:38 PM] Sending notification 'textDocument/didSave'.
2023-08-27 15:10:38.729 [info] [Trace - 3:10:38 PM] Received notification 'window/logMessage'.
2023-08-27 15:10:38.729 [info] c:\Projects\leetcode\.venv\Scripts\python.exe -m mypy.dmypy --status-file C:\Users\jesse\AppData\Local\Temp\.vscode.dmypy_status\status-71ba2c32-0ae8-4583-ad96-9de98c49f070.json run -- --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-error-end c:\Projects\leetcode\test.py
2023-08-27 15:10:38.729 [info] [Trace - 3:10:38 PM] Received notification 'window/logMessage'.
2023-08-27 15:10:38.729 [info] CWD Server: c:\Projects\leetcode
2023-08-27 15:10:38.832 [info] [Trace - 3:10:38 PM] Received notification 'window/logMessage'.
2023-08-27 15:10:38.832 [info] file:///c%3A/Projects/leetcode/test.py :

When restarting the server I get the following output:

2023-08-27 15:05:54.120 [info] [Trace - 3:05:54 PM] Received response 'shutdown - (1)' in 99ms.
2023-08-27 15:05:54.120 [info] [Trace - 3:05:54 PM] Sending notification 'exit'.
2023-08-27 15:05:54.121 [info] No interpreter found from setting mypy-type-checker.interpreter
2023-08-27 15:05:54.121 [info] Getting interpreter from ms-python.python extension for workspace c:\Projects\leetcode
2023-08-27 15:05:54.122 [info] Interpreter from ms-python.python extension for c:\Projects\leetcode: c:\Projects\leetcode\.venv\Scripts\python.exe
2023-08-27 15:05:54.125 [info] Server run command: c:\Projects\leetcode\.venv\Scripts\python.exe c:\Users\jesse\.vscode\extensions\ms-python.mypy-type-checker-2023.3.12361006\bundled\tool\lsp_server.py
2023-08-27 15:05:54.127 [info] Server: Start requested.
2023-08-27 15:05:54.583 [info] CWD Server: c:\Projects\leetcode
2023-08-27 15:05:54.583 [info] Settings used to run Server:
[
    {
        "cwd": "c:\\Projects\\leetcode",
        "workspace": "file:///c%3A/Projects/leetcode",
        "args": [],
        "severity": {
            "error": "Error",
            "note": "Information"
        },
        "path": [],
        "interpreter": [
            "c:\\Projects\\leetcode\\.venv\\Scripts\\python.exe"
        ],
        "importStrategy": "useBundled",
        "showNotifications": "off",
        "extraPaths": [],
        "reportingScope": "file"
    }
]

2023-08-27 15:05:54.583 [info] Global settings:
{
    "cwd": "C:\\Program Files\\Microsoft VS Code",
    "workspace": "C:\\Program Files\\Microsoft VS Code",
    "args": [],
    "severity": {
        "error": "Error",
        "note": "Information"
    },
    "path": [],
    "interpreter": [],
    "importStrategy": "useBundled",
    "showNotifications": "off",
    "extraPaths": [],
    "reportingScope": "file"
}

2023-08-27 15:05:54.584 [info] sys.path used to run Server:
   c:\Projects\leetcode
   c:\Users\jesse\.vscode\extensions\ms-python.mypy-type-checker-2023.3.12361006\bundled\libs
   c:\Users\jesse\.vscode\extensions\ms-python.mypy-type-checker-2023.3.12361006\bundled\tool
   C:\Users\jesse\AppData\Local\Programs\Python\Python310\python310.zip
   C:\Users\jesse\AppData\Local\Programs\Python\Python310\DLLs
   C:\Users\jesse\AppData\Local\Programs\Python\Python310\lib
   C:\Users\jesse\AppData\Local\Programs\Python\Python310
   c:\Projects\leetcode\.venv
   c:\Projects\leetcode\.venv\lib\site-packages
2023-08-27 15:05:54.587 [info] c:\Projects\leetcode\.venv\Scripts\python.exe -m mypy.dmypy --version
2023-08-27 15:05:54.587 [info] CWD Server: c:\Projects\leetcode
2023-08-27 15:05:54.682 [info] 
dmypy 1.5.0


2023-08-27 15:05:54.682 [info] Version info for linter running for C:\Projects\leetcode:
dmypy 1.5.0

2023-08-27 15:05:54.682 [info] SUPPORTED mypy>=1.0.0
FOUND mypy==1.5.0

2023-08-27 15:05:54.688 [info] [Trace - 3:05:54 PM] Received notification 'window/logMessage'.
2023-08-27 15:05:54.688 [info] c:\Projects\leetcode\.venv\Scripts\python.exe -m mypy.dmypy --status-file C:\Users\jesse\AppData\Local\Temp\.vscode.dmypy_status\status-ed4b212a-b4b5-4924-97cb-eaa37910b609.json run -- --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-error-end c:\Projects\leetcode\test.py
2023-08-27 15:05:54.688 [info] [Trace - 3:05:54 PM] Received notification 'window/logMessage'.
2023-08-27 15:05:54.688 [info] CWD Server: c:\Projects\leetcode
2023-08-27 15:05:57.615 [info] [Trace - 3:05:57 PM] Received notification 'window/logMessage'.
2023-08-27 15:05:57.615 [info] file:///c%3A/Projects/leetcode/test.py :
Daemon started
c:\Projects\leetcode\test.py:2:12:2:17: error: Incompatible return value type (got "str", expected "int")  [return-value]

2023-08-27 15:05:57.615 [info] [Trace - 3:05:57 PM] Received notification 'window/logMessage'.
2023-08-27 15:05:57.615 [info] file:///c%3A/Projects/leetcode/test.py :
Daemon started
c:\Projects\leetcode\test.py:2:12:2:17: error: Incompatible return value type (got "str", expected "int")  [return-value]

2023-08-27 15:05:57.616 [info] [Trace - 3:05:57 PM] Received notification 'textDocument/publishDiagnostics'.

[Bug] Does one analysis at start, and never re analyses the file unless VSCode is closed and reopened

Installed the mypy release version v2023.2.0

Reloaded VSCode after install

It correctly linted my file at the start (16 problems)

I modified my file, try adding an additional problem

Then the problem window is empty

Tried to save the file, close & open the file, nothing works

BUT closing VSCode & Re-opening it works, the file is linted again

If I make a new modification, again, "No problem" is shown and no new analysis results are displayed

It is on Windows but using a remote Linux through SSH

Settings are :

"mypy-type-checker.interpreter": [
    ".venv/bin/python"
],
"mypy-type-checker.args": [
    "--explicit-package-bases"
],

Errors disappear after saving any changes to file

Errors from mypy disappear after saving any change to a file. It doesn't matter if the change fixes an error, introduces a new error or is not related at all. Only reloading VS Code window fixes it until you make a change once again. This basically makes this extension unusable.

mypy-related settings in my settings.json:

{
  "python.linting.mypyEnabled": false
}

When set to false:

image

Errors only reported by Python extension.

When set to true:

image

Errors reported by this and Python extension.

After having saved changes when set to true:

image

Error from this extension disappears while the one from Python extension stays.

Logs of this extension after saving changes which cause errors to disappear:

2023-07-14 14:12:20.364 [info] /Users/levrik/code/<REDACTED>/.venv/bin/python -m mypy.dmypy --status-file /var/folders/y5/_yxr_tgx3xggc344718g4fp00000gn/T/.vscode.dmypy_status/status-f7231085-f699-494e-93e9-916f03e88602.json run -- --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-code --no-pretty --follow-imports=normal --show-error-end /Users/levrik/code/<REDACTED>.py
2023-07-14 14:12:20.364 [info] [Trace - 2:12:20 PM] Received notification 'window/logMessage'.
2023-07-14 14:12:20.364 [info] CWD Server: /Users/levrik/code/<REDACTED>
2023-07-14 14:12:20.437 [info] [Trace - 2:12:20 PM] Received notification 'window/logMessage'.
2023-07-14 14:12:20.437 [info] file:///Users/levrik/code/<REDACTED>.py :

2023-07-14 14:12:20.439 [info] [Trace - 2:12:20 PM] Received notification 'textDocument/publishDiagnostics'.

vscode-python causing silent dmypy failure

Problem

No mypy type hints ๐Ÿ˜ข

Cause

Seems like the default settings for vscode-python is setting python.linting.mypyArgs with an arg of --follow-imports=silent which is not supported by dmypy (python/mypy#9475)

Workaround

Set "python.linting.mypyArgs": [], in user or workspace settings.json

Potential fix

Would a fix be to just stop reading the legacy args here?
Happy to try a PR if so ๐Ÿ˜‰

My reasoning: Given these legacy args are being deprecated in favour of plugins like this one? And that maybe the change to dmypy (#53) now warrants this?

I'm fairly new to the Python world so I hope this makes some sense ๐Ÿ˜…

Demo

In defaultSettings.json we can see python.linting.mypyArgs with an arg of --follow-imports=silent

image

We can see that vscode-mypy now reads this setting

image

And when it passes the arg to dmypy we get a message to say it's not supported, and we do not get Daemon started

image

After using the workaround we can see Daemon started and a type error in the console

image

and in the editor

image

Automatically use mypy.ini or pyproject.toml when not in the root directory of the workspace

When using the Mypy linter, our standard is to have a mypy.ini in the project's root with a bunch of config values. Currently we have our developers use this setting for vscode:

  "python.linting.mypyArgs": [
    "--config-file=${workspaceFolder}/mypy.ini"
  ]

However, if a project doesn't have a mypy.ini file linting fails silently (which can cause a lot of issues as a dev might think that mypy worked fine).

I think that auto-detecting and using the mypy.ini file should be a part of the plugin itself.

Document Default Interpreter

The mypy-type-checker.interpreter setting is helpfully documented in the README:

Path to a python interpreter to use to run the linter server.

The default value is [], but it isn't immediately clear what interpreter is used in this case. For instance, is python.defaultInterpreterPath used, or does the mypy extension ship with a Python interpreter?

Rogue "missing return statement" errors

I am running the latest pre-release version of the extension with mypy 1.4.0 in the environment with "mypy-type-checker.importStrategy": "fromEnvironment".

Quite often when opening a file, I am greeted with the following error on most of the lines:

Missing return statement [return]

Upon opening the extension logs, I can see that these errors appear to be coming from one or more type stubs:

2023-06-22 15:17:44.757 [info] [Trace - 3:17:44 PM] Received notification 'window/logMessage'.
2023-06-22 15:17:44.758 [info] file:///c%3A/Users/me/Documents/GitHub/project/some/file.py :
.venv\lib\site-packages\requests-stubs\api.pyi:10:1:28:18: error: Missing return statement  [return]
...
.venv\lib\site-packages\requests-stubs\api.pyi:137:1:154:18: error: Missing return statement  [return]
.venv\lib\site-packages\requests-stubs\sessions.pyi:315:1:315:29: error: Missing return statement  [return]
.venv\lib\site-packages\requests-stubs\utils.pyi:25:1:25:88: error: Missing return statement  [return]
...
.venv\lib\site-packages\requests-stubs\utils.pyi:68:5:68:44: error: Missing return statement  [return]
.venv\lib\site-packages\urllib3-stubs\filepost.pyi:14:1:14:33: error: Missing return statement  [return]
.venv\lib\site-packages\urllib3-stubs\filepost.pyi:15:1:15:75: error: Missing return statement  [return]
.venv\lib\site-packages\urllib3-stubs\filepost.pyi:17:1:17:106: error: Missing return statement  [return]

I don't see any of these errors when running mypy .

I tried adding exclude = [".venv/"] to my pyproject.toml file to no avail.

Mypy VSCode extension won't show errors from source code

Error in Mypy type checker extension output:

2023-09-01 22:46:53.853 [info] /home/user/anaconda3/envs/some_env/bin/python -m mypy.dmypy --status-file /tmp/.vscode.dmypy_status/status-3de074ac-29b4-4792-b9c2-7d63057e823d.json run -- --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-code --no-pretty --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty --show-error-end /home/user/projects/some_project/src/script.py
2023-09-01 22:46:53.853 [info] CWD Server: /home/user/projects/some_project
2023-09-01 22:46:54.065 [info] usage: mypy [-h] [-v] [-V] [more options; see below]
            [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: ambiguous option: --show-error-code could match --show-error-codes, --show-error-code-links

Mypy related settings in vscode json:

	"mypy-type-checker.importStrategy": "fromEnvironment",

VSCode: 1.81.1
VSCode extensions:

  • mypy-type-checker: 2023.2.0
  • python: 2023.14.0

Python: 3.11.5
Mypy in conda environment: 1.5.1

Ambiguous option --show-error-code

When using mypy-type-checker.importStrategy: "fromEnvironment", I see the following errors in Mypy Type Checker output:

2023-08-26 13:50:13.145 [info] usage: mypy [-h] [-v] [-V] [more options; see below]
            [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: ambiguous option: --show-error-code could match --show-error-codes, --show-error-code-links

The environment mypy version is 1.5.1.

Error: spawn [...] ENOENT

Ever since installing the extension I'm getting this error, and reselecting the interpreter does not fix it:

2023-07-11 09:01:17.355 [info] No interpreter found from setting mypy-type-checker.interpreter
2023-07-11 09:01:17.355 [info] Getting interpreter from ms-python.python extension for workspace /Users/underyx/r2c/app
2023-07-11 09:01:17.357 [info] Interpreter from ms-python.python extension for /Users/underyx/r2c/app: /Users/underyx/r2c/app/server/.venv/bin/python
2023-07-11 09:01:17.358 [info] Using cwd from `python.linting.cwd`.
2023-07-11 09:01:17.361 [info] Server run command: /Users/underyx/r2c/app/server/.venv/bin/python /Users/underyx/.vscode/extensions/ms-python.mypy-type-checker-2023.1.11911749/bundled/tool/lsp_server.py
2023-07-11 09:01:17.361 [info] Server: Start requested.
2023-07-11 09:01:17.449 [info] [Error - 9:01:17 AM] Mypy Type Checker client: couldn't create connection to server.
2023-07-11 09:01:17.449 [info] Launching server using command /Users/underyx/r2c/app/server/.venv/bin/python failed. Error: spawn /Users/underyx/r2c/app/server/.venv/bin/python ENOENT
2023-07-11 09:01:17.449 [error] Server: Start failed: Launching server using command /Users/underyx/r2c/app/server/.venv/bin/python failed. Error: spawn /Users/underyx/r2c/app/server/.venv/bin/python ENOENT

even though

(semgrep-app-py3.11) underyx@san app % /Users/underyx/r2c/app/server/.venv/bin/python --version
Python 3.11.0

This is using v2023.1.11921011 of ms-python.mypy-type-checker.

Errors don't clear up after being fixed

from typing import Any

def foo(a: Any, b: Any) -> bool:
    return (a == b)

The above code fails with a "Returning Any from function declared to return "bool" (Mypy no-any-return)", which is understandable. The problem manifest once I fix it:

from typing import Any

def foo(a: Any, b: Any) -> bool:
    return bool(a == b)

The return statement remains annotated with the same error, even though it is fixed now. The error only goes away if I restart VScode. I can also delete the entire line, save, then re-add it, which will fix the return type error, but will leave me with a different stale error: "expected an indented block after function definition on line 4 (Mypy syntax)", which was raised while the row was deleted.

I'm running pre-release version v2023.3.12421009 because of the --show-error-code bug still not fixed on the stable channel. There are no obvious problems logged in the Mypy Type Checker output stream.

Daemon crashed! - RecursionError: maximum recursion depth exceeded

Source file: posita/dyce/dyce/evaluation.py

Relevant settings:

{
  // ...
  "[python]": {
    "editor.codeActionsOnSave": {
      "source.fixAll": true,
      "source.organizeImports": true
    },
    "editor.defaultFormatter": "ms-python.black-formatter"
  },
  "isort.check": true,
  "python.defaultInterpreterPath": "/home/<username>/.virtualenvs/dyce/bin/python",
  "python.experiments.enabled": false,
  "python.linting.mypyArgs": []
}
Logs:
2023-08-27 12:43:03.583 [info] /home/<username>/.virtualenvs/dyce/bin/python -m mypy.dmypy --status-file /tmp/.vscode.dmypy_status/status-1c6d0227-f415-4160-8029-a3acd2ec57e7.json run -- --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-code --no-pretty --show-error-end /home/<username>/<path>/dyce/dyce/evaluation.py
2023-08-27 12:43:03.583 [info] CWD Server: /home/<username>/<path>/dyce
2023-08-27 12:43:07.330 [info] Daemon crashed!
Traceback (most recent call last):
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/dmypy_server.py", line 234, in serve
    resp = self.run_command(command, data)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/dmypy_server.py", line 281, in run_command
    ret = method(self, **data)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/dmypy_server.py", line 349, in cmd_run
    return self.check(sources, export_types, is_tty, terminal_width)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/dmypy_server.py", line 418, in check
    messages = self.fine_grained_increment_follow_imports(sources)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/dmypy_server.py", line 603, in fine_grained_increment_follow_imports
    messages = fine_grained_manager.update(changed, [], followed=True)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/server/update.py", line 267, in update
    result = self.update_one(
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/server/update.py", line 369, in update_one
    result = self.update_module(next_id, next_path, next_id in removed_set, followed)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/server/update.py", line 431, in update_module
    result = update_module_isolated(
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/server/update.py", line 618, in update_module_isolated
    load_graph(sources, manager, graph, new_modules)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/build.py", line 3142, in load_graph
    newst = State(
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/build.py", line 2000, in __init__
    self.parse_file()
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/build.py", line 2176, in parse_file
    self.tree = manager.parse_file(
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/build.py", line 841, in parse_file
    tree = parse(source, path, id, self.errors, options=options)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/parse.py", line 22, in parse
    return mypy.fastparse.parse(source, fnam=fnam, module=module, errors=errors, options=options)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 293, in parse
    ).visit(ast)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 921, in visit_Module
    body = self.fix_function_overloads(self.translate_stmt_list(mod.body, ismodule=True))
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 536, in translate_stmt_list
    node = self.visit(stmt)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1221, in visit_Assign
    rvalue = self.visit(n.value)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1494, in visit_Dict
    list(zip(self.translate_opt_expr_list(n.keys), self.translate_expr_list(n.values)))
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 480, in translate_expr_list
    return cast(List[Expression], self.translate_opt_expr_list(l))
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 475, in translate_opt_expr_list
    exp = self.visit(e)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1716, in visit_List
    expr_list: list[Expression] = [self.visit(e) for e in n.elts]
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1716, in <listcomp>
    expr_list: list[Expression] = [self.visit(e) for e in n.elts]
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1481, in visit_Lambda
    e = LambdaExpr(self.transform_args(n.args, n.lineno), self.as_required_block([body]))
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 651, in as_required_block
    self.translate_stmt_list(stmts, can_strip=can_strip, is_coroutine=is_coroutine)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 536, in translate_stmt_list
    node = self.visit(stmt)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1205, in visit_Return
    node = ReturnStmt(self.visit(n.value))
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1453, in visit_BinOp
    e = OpExpr(op, self.visit(n.left), self.visit(n.right))
...
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1453, in visit_BinOp
    e = OpExpr(op, self.visit(n.left), self.visit(n.right))
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 462, in visit
    return visitor(node)
  File "/home/<username>/.vscode/extensions/ms-python.mypy-type-checker-2023.2.0/bundled/libs/mypy/fastparse.py", line 1448, in visit_BinOp
    op = self.from_operator(n.op)
RecursionError: maximum recursion depth exceeded


2023-08-27 12:43:07.331 [info] file:///home/<username>/<path>/dyce/dyce/evaluation.py :

What is strange about the above is, if I run the command that prompts the RecursionError by hand in a fresh shell (no virtualenv), I get this:

% /home/<username>/.virtualenvs/dyce/bin/python -m mypy.dmypy --status-file /tmp/.vscode.dmypy_status/status-1c6d0227-f415-4160-8029-a3acd2ec57e7.json run -- --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-code --no-pretty --show-error-end /home/<username>/<path>/dyce/dyce/evaluation.py
usage: mypy [-h] [-v] [-V] [more options; see below]
            [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: ambiguous option: --show-error-code could match --show-error-codes, --show-error-code-links

Which is a different error than I get above. If I correct for that issue (#125), I get no error:

% /home/<username>/.virtualenvs/dyce/bin/python -m mypy.dmypy --status-file /tmp/.vscode.dmypy_status/status-1c6d0227-f415-4160-8029-a3acd2ec57e7.json run -- --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-code --no-pretty --show-error-end /home/<username>/<path>/dyce/dyce/evaluation.py
Daemon started

Context:

% uname -prism
Linux 6.4.6-76060406-generic x86_64 x86_64 x86_64
% /home/<username>/.virtualenvs/dyce/bin/python --version
Python 3.10.12
% /home/<username>/.virtualenvs/dyce/bin/python -m mypy --version
mypy 1.5.1 (compiled: yes)
% /home/<username>/.virtualenvs/dyce/bin/python -m mypy.dmypy --version
dmypy 1.5.1

Errors remain after being fixed, until file is reopened

(using pre-release v2023.3.12361006, because the current release doesn't work at all due to a stray --follow-imports=silent option)

Steps to reproduce:

  1. Create a file with:
def temp() -> str:
    return "0"
  1. Observe there are no type errors (as expected).
  2. Change line 2 to return 0
  3. Observe there is now a type error complaining about the incorrect int return value.
  4. Fix the bug by updating the code again to return "0"
  5. Observe that the error is still displayed, even though there is no error now in the Mypy Type Checker output tab.
  6. Close file and reopen, observe that the error is now gone.

Mypy not showing errors on newly created files

This is when "mypy-type-checker.reportingScope" is set to "workspace"

If you create new files with errors reported by mypy, it won't report their errors until you restart the server.

Repro steps:

  • Create new files with problems mypy should report
  • Notice they are not reported as problems
mypynewfilelintallbug.mp4

Feature request: Offer "# type: ignore" quick fix for line and entire file

I would like to request for the extension to offer a Quick Fix to suppress an error by adding:

  • # type: ignore[error-code] at the end of the line
  • or # mypy: disable-error-code="error-code" to the top of the file

Similar to how ESLint does it
image

And better than pylance does it by also including the error code:
image

IntelliSense and mypy config support

Hello โ€” I found this project while looking for mypy support in VS Code. I noticed Pylance uses Pyright for IntelliSense tips (on hover, etc.) but we use mypy in our project.

Is Intellisense support already built? When I installed the pre-release version, I did not see any type hints show on hover.

Similarly, is there support for reading mypy config from a pyproject.toml or setup.cfg file, or does this extension only support .ini files?

Thanks for working on this!

"Server initialization failed" with Poetry environment

Using mypy v1.4.1 under a poetry environment (properly setup in VSCode project) and I get the following crash report right after VS Code is launched:

2023-07-31 13:07:26.631 [info] Interpreter from setting mypy-type-checker.interpreter: /home/user/.cache/pypoetry/virtualenvs/tariff-tools-sOhTbMWF-py3.7/bin/python
2023-07-31 13:07:26.631 [info] Using legacy Mypy args from 'python.linting.mypyArgs': --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty.
2023-07-31 13:07:26.631 [info] Server: Stop requested
2023-07-31 13:07:26.631 [error] Server: Stop failed: Error: Client is not running and can't be stopped. It's current state is: startFailed
2023-07-31 13:07:26.631 [info] Interpreter from setting mypy-type-checker.interpreter: /home/user/.cache/pypoetry/virtualenvs/tariff-tools-sOhTbMWF-py3.7/bin/python
2023-07-31 13:07:26.632 [info] Using legacy Mypy args from 'python.linting.mypyArgs': --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty.
2023-07-31 13:07:26.635 [info] Server run command: /home/user/.cache/pypoetry/virtualenvs/tariff-tools-sOhTbMWF-py3.7/bin/python /home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py
2023-07-31 13:07:26.636 [info] Server: Start requested.
2023-07-31 13:07:27.417 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:27.533 [info] [Error - 13:07:27] Server initialization failed.
2023-07-31 13:07:27.533 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:27.533 [info] [Info  - 13:07:27] Connection to server got closed. Server will restart.
2023-07-31 13:07:27.533 [info] true
2023-07-31 13:07:27.533 [info] [Error - 13:07:27] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:27.533 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:28.275 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:28.381 [info] [Error - 13:07:28] Server initialization failed.
2023-07-31 13:07:28.381 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:28.381 [info] [Info  - 13:07:28] Connection to server got closed. Server will restart.
2023-07-31 13:07:28.381 [info] true
2023-07-31 13:07:28.381 [info] [Error - 13:07:28] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:28.381 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:28.382 [error] Server: Start failed: Error: Pending response rejected since connection got disposed
2023-07-31 13:07:29.149 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:29.251 [info] [Error - 13:07:29] Server initialization failed.
2023-07-31 13:07:29.251 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:29.251 [info] [Info  - 13:07:29] Connection to server got closed. Server will restart.
2023-07-31 13:07:29.251 [info] true
2023-07-31 13:07:29.252 [info] [Error - 13:07:29] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:29.252 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:29.252 [info] [Error - 13:07:29] Restarting server failed
2023-07-31 13:07:29.252 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.002 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:30.094 [info] [Error - 13:07:30] Server initialization failed.
2023-07-31 13:07:30.094 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.094 [info] [Info  - 13:07:30] Connection to server got closed. Server will restart.
2023-07-31 13:07:30.094 [info] true
2023-07-31 13:07:30.095 [info] [Error - 13:07:30] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:30.095 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.095 [info] [Error - 13:07:30] Restarting server failed
2023-07-31 13:07:30.095 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.835 [info] Traceback (most recent call last):
  File "/home/user/.vscode/extensions/ms-python.mypy-type-checker-2023.1.12061012/bundled/tool/lsp_server.py", line 49, in <module>
    name="Mypy", version="v0.1.0", max_workers=MAX_WORKERS
TypeError: __init__() got an unexpected keyword argument 'name'

2023-07-31 13:07:30.926 [info] [Error - 13:07:30] Server initialization failed.
2023-07-31 13:07:30.926 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.926 [info] [Error - 13:07:30] The Mypy Type Checker server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
2023-07-31 13:07:30.926 [info] [Error - 13:07:30] Mypy Type Checker client: couldn't create connection to server.
2023-07-31 13:07:30.927 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-07-31 13:07:30.927 [info] [Error - 13:07:30] Restarting server failed
2023-07-31 13:07:30.927 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 

Mypy not showing type errors

Steps to reproduce:

  1. Clone https://github.com/luabud/wordle
  2. Open the wordle.py file
  3. Add parameter type str on line 21
    def wrong_guess_length(guess_word: str):
  4. On line 49, pass a parameter of a different type to the function (e.g. "10")
  5. Only Pylance shows the type error:
    image

It works fine if I e.g. create a new file and do something similar:
image

Logs
2023-04-10 11:18:08.286 [info] Server run command: c:\REDACTED\Apps\wordle\.venv\Scripts\python.exe c:\REDACTED\.vscode-insiders\extensions\ms-python.mypy-type-checker-2023.1.10951005\bundled\tool\lsp_server.py
2023-04-10 11:18:08.286 [info] Server: Start requested.
2023-04-10 11:18:12.925 [info] CWD Server: c:\REDACTED\Apps\wordle
2023-04-10 11:18:12.925 [info] Settings used to run Server:
[
    {
        "cwd": "c:\\REDACTED\\Apps\\wordle",
        "workspace": "file:///c%3A/REDACTED/Apps/wordle",
        "args": [
            "--follow-imports=silent",
            "--ignore-missing-imports",
            "--no-pretty"
        ],
        "severity": {
            "error": "Error",
            "note": "Information"
        },
        "path": [],
        "interpreter": [
            "c:\\REDACTED\\Apps\\wordle\\.venv\\Scripts\\python.exe"
        ],
        "importStrategy": "useBundled",
        "showNotifications": "off",
        "extraPaths": []
    }
]

2023-04-10 11:18:12.926 [info] Global settings:
{
    "cwd": "C:\\REDACTED\\AppData\\Local\\Programs\\Microsoft VS Code Insiders",
    "workspace": "C:\\REDACTED\\AppData\\Local\\Programs\\Microsoft VS Code Insiders",
    "args": [
        "--follow-imports=silent",
        "--ignore-missing-imports",
        "--no-pretty"
    ],
    "severity": {
        "error": "Error",
        "note": "Information"
    },
    "path": [],
    "interpreter": [],
    "importStrategy": "useBundled",
    "showNotifications": "off",
    "extraPaths": []
}

2023-04-10 11:18:12.926 [info] sys.path used to run Server:
   c:\REDACTED\Apps\wordle
   c:\REDACTED\.vscode-insiders\extensions\ms-python.mypy-type-checker-2023.1.10951005\bundled\libs
   c:\REDACTED\.vscode-insiders\extensions\ms-python.mypy-type-checker-2023.1.10951005\bundled\tool
   C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1008.0_x64__qbz5n2kfra8p0\python311.zip
   C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1008.0_x64__qbz5n2kfra8p0\DLLs
   C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1008.0_x64__qbz5n2kfra8p0\Lib
   C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1008.0_x64__qbz5n2kfra8p0
   c:\REDACTED\Apps\wordle\.venv
   c:\REDACTED\Apps\wordle\.venv\Lib\site-packages
2023-04-10 11:18:12.964 [info] c:\REDACTED\Apps\wordle\.venv\Scripts\python.exe -m mypy --version
2023-04-10 11:18:12.964 [info] CWD Linter: c:\REDACTED\Apps\wordle
2023-04-10 11:18:14.358 [info] 
mypy 1.1.1 (compiled: no)


2023-04-10 11:18:14.358 [info] Version info for linter running for c:\REDACTED\Apps\wordle:
mypy 1.1.1 (compiled: no)

2023-04-10 11:18:14.358 [info] SUPPORTED mypy>=1.0.0
FOUND mypy==1.1.1

2023-04-10 11:18:14.368 [info] [Trace - 11:18:14 AM] Received notification 'window/logMessage'.
2023-04-10 11:18:14.368 [info] c:\REDACTED\Apps\wordle\.venv\Scripts\python.exe -m mypy --no-color-output --no-error-summary --show-column-numbers --show-error-code --follow-imports=silent --ignore-missing-imports --no-pretty --show-error-end c:\REDACTED\Apps\wordle\wordle.py
2023-04-10 11:18:14.368 [info] [Trace - 11:18:14 AM] Received notification 'window/logMessage'.
2023-04-10 11:18:14.368 [info] CWD Linter: c:\REDACTED\Apps\wordle
2023-04-10 11:18:14.484 [info] [Trace - 11:18:14 AM] Received notification 'window/logMessage'.
2023-04-10 11:18:14.484 [info] file:///c%3A/REDACTED/Apps/wordle/wordle.py :

2023-04-10 11:18:14.486 [info] [Trace - 11:18:14 AM] Received notification 'textDocument/publishDiagnostics'.
2023-04-10 11:19:45.826 [info] [Trace - 11:19:45 AM] Sending notification 'textDocument/didClose'.
2023-04-10 11:19:45.829 [info] [Trace - 11:19:45 AM] Received notification 'textDocument/publishDiagnostics'.
2023-04-10 11:19:51.909 [info] [Trace - 11:19:51 AM] Sending notification 'textDocument/didOpen'.
2023-04-10 11:19:51.912 [info] [Trace - 11:19:51 AM] Received notification 'window/logMessage'.
2023-04-10 11:19:51.912 [info] c:\REDACTED\Apps\wordle\.venv\Scripts\python.exe -m mypy --no-color-output --no-error-summary --show-column-numbers --show-error-code --follow-imports=silent --ignore-missing-imports --no-pretty --show-error-end c:\REDACTED\Apps\wordle\hello.py
2023-04-10 11:19:51.913 [info] [Trace - 11:19:51 AM] Received notification 'window/logMessage'.
2023-04-10 11:19:51.913 [info] CWD Linter: c:\REDACTED\Apps\wordle
2023-04-10 11:19:52.266 [info] [Trace - 11:19:52 AM] Received notification 'window/logMessage'.
2023-04-10 11:19:52.266 [info] file:///c%3A/REDACTED/Apps/wordle/hello.py :

2023-04-10 11:19:52.266 [info] [Trace - 11:19:52 AM] Received notification 'textDocument/publishDiagnostics'.
2023-04-10 11:19:54.440 [info] [Trace - 11:19:54 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:54.566 [info] [Trace - 11:19:54 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:54.747 [info] [Trace - 11:19:54 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:54.810 [info] [Trace - 11:19:54 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:54.889 [info] [Trace - 11:19:54 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:54.997 [info] [Trace - 11:19:54 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:55.265 [info] [Trace - 11:19:55 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:57.269 [info] [Trace - 11:19:57 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:57.485 [info] [Trace - 11:19:57 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:57.650 [info] [Trace - 11:19:57 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:57.726 [info] [Trace - 11:19:57 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:57.826 [info] [Trace - 11:19:57 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:57.922 [info] [Trace - 11:19:57 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:58.029 [info] [Trace - 11:19:58 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:58.220 [info] [Trace - 11:19:58 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:58.227 [info] [Trace - 11:19:58 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:58.273 [info] [Trace - 11:19:58 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:58.439 [info] [Trace - 11:19:58 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:58.747 [info] [Trace - 11:19:58 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:58.755 [info] [Trace - 11:19:58 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:58.885 [info] [Trace - 11:19:58 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:59.014 [info] [Trace - 11:19:59 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:59.170 [info] [Trace - 11:19:59 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:59.314 [info] [Trace - 11:19:59 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:59.425 [info] [Trace - 11:19:59 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:59.528 [info] [Trace - 11:19:59 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:19:59.666 [info] [Trace - 11:19:59 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:00.568 [info] [Trace - 11:20:00 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:00.638 [info] [Trace - 11:20:00 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:00.806 [info] [Trace - 11:20:00 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.002 [info] [Trace - 11:20:00 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.256 [info] [Trace - 11:20:01 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.382 [info] [Trace - 11:20:01 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.433 [info] [Trace - 11:20:01 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.478 [info] [Trace - 11:20:01 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.562 [info] [Trace - 11:20:01 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.637 [info] [Trace - 11:20:01 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.742 [info] [Trace - 11:20:01 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:01.939 [info] [Trace - 11:20:01 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:05.794 [info] [Trace - 11:20:05 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:07.078 [info] [Trace - 11:20:07 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:07.173 [info] [Trace - 11:20:07 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:07.231 [info] [Trace - 11:20:07 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:07.358 [info] [Trace - 11:20:07 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:07.406 [info] [Trace - 11:20:07 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:07.434 [info] [Trace - 11:20:07 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:07.493 [info] [Trace - 11:20:07 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:07.597 [info] [Trace - 11:20:07 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:08.284 [info] [Trace - 11:20:08 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:08.525 [info] [Trace - 11:20:08 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:08.703 [info] [Trace - 11:20:08 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:08.796 [info] [Trace - 11:20:08 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:08.878 [info] [Trace - 11:20:08 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:08.908 [info] [Trace - 11:20:08 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:08.976 [info] [Trace - 11:20:08 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:09.149 [info] [Trace - 11:20:09 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:09.305 [info] [Trace - 11:20:09 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:09.816 [info] [Trace - 11:20:09 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:09.990 [info] [Trace - 11:20:09 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:10.330 [info] [Trace - 11:20:10 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:12.337 [info] [Trace - 11:20:12 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:12.514 [info] [Trace - 11:20:12 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:12.561 [info] [Trace - 11:20:12 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:14.322 [info] [Trace - 11:20:14 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:14.401 [info] [Trace - 11:20:14 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:14.500 [info] [Trace - 11:20:14 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:14.720 [info] [Trace - 11:20:14 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:14.722 [info] [Trace - 11:20:14 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:14.881 [info] [Trace - 11:20:14 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:14.972 [info] [Trace - 11:20:14 AM] Sending notification 'textDocument/didChange'.
2023-04-10 11:20:15.272 [info] [Trace - 11:20:15 AM] Sending notification 'textDocument/didSave'.
2023-04-10 11:20:15.275 [info] [Trace - 11:20:15 AM] Received notification 'window/logMessage'.
2023-04-10 11:20:15.275 [info] c:\REDACTED\Apps\wordle\.venv\Scripts\python.exe -m mypy --no-color-output --no-error-summary --show-column-numbers --show-error-code --follow-imports=silent --ignore-missing-imports --no-pretty --show-error-end c:\REDACTED\Apps\wordle\hello.py
2023-04-10 11:20:15.276 [info] [Trace - 11:20:15 AM] Received notification 'window/logMessage'.
2023-04-10 11:20:15.276 [info] CWD Linter: c:\REDACTED\Apps\wordle
2023-04-10 11:20:15.589 [info] [Trace - 11:20:15 AM] Received notification 'window/logMessage'.
2023-04-10 11:20:15.589 [info] file:///c%3A/REDACTED/Apps/wordle/hello.py :
hello.py:4:5:4:6: error: Argument 1 to "bla" has incompatible type "int"; expected "str"  [arg-type]

2023-04-10 11:20:15.590 [info] [Trace - 11:20:15 AM] Received notification 'window/logMessage'.
2023-04-10 11:20:15.590 [info] file:///c%3A/REDACTED/Apps/wordle/hello.py :
hello.py:4:5:4:6: error: Argument 1 to "bla" has incompatible type "int"; expected "str"  [arg-type]

2023-04-10 11:20:15.590 [info] [Trace - 11:20:15 AM] Received notification 'textDocument/publishDiagnostics'.
2023-04-10 11:20:19.932 [info] [Trace - 11:20:19 AM] Sending notification 'textDocument/didOpen'.
2023-04-10 11:20:19.935 [info] [Trace - 11:20:19 AM] Received notification 'window/logMessage'.
2023-04-10 11:20:19.935 [info] c:\REDACTED\Apps\wordle\.venv\Scripts\python.exe -m mypy --no-color-output --no-error-summary --show-column-numbers --show-error-code --follow-imports=silent --ignore-missing-imports --no-pretty --show-error-end c:\REDACTED\Apps\wordle\wordle.py
2023-04-10 11:20:19.935 [info] [Trace - 11:20:19 AM] Received notification 'window/logMessage'.
2023-04-10 11:20:19.935 [info] CWD Linter: c:\REDACTED\Apps\wordle
2023-04-10 11:20:20.045 [info] [Trace - 11:20:20 AM] Received notification 'window/logMessage'.
2023-04-10 11:20:20.045 [info] file:///c%3A/REDACTED/Apps/wordle/wordle.py :

2023-04-10 11:20:20.046 [info] [Trace - 11:20:20 AM] Received notification 'textDocument/publishDiagnostics'.
2023-04-10 11:20:23.227 [info] [Trace - 11:20:23 AM] Sending notification 'textDocument/didClose'.
2023-04-10 11:20:23.230 [info] [Trace - 11:20:23 AM] Received notification 'textDocument/publishDiagnostics'.
2023-04-10 11:21:01.044 [info] c:\REDACTED\Apps\wordle\.venv\Scripts\python.exe -m mypy --no-color-output --no-error-summary --show-column-numbers --show-error-code --follow-imports=silent --ignore-missing-imports --no-pretty --show-error-end c:\REDACTED\Apps\wordle\wordle.py
2023-04-10 11:21:01.044 [info] CWD Linter: c:\REDACTED\Apps\wordle
2023-04-10 11:21:01.457 [info] file:///c%3A/REDACTED/Apps/wordle/wordle.py :

2023-04-10 11:21:04.263 [info] c:\REDACTED\Apps\wordle\.venv\Scripts\python.exe -m mypy --no-color-output --no-error-summary --show-column-numbers --show-error-code --follow-imports=silent --ignore-missing-imports --no-pretty --show-error-end c:\REDACTED\Apps\wordle\wordle.py
2023-04-10 11:21:04.263 [info] CWD Linter: c:\REDACTED\Apps\wordle
2023-04-10 11:21:04.980 [info] file:///c%3A/REDACTED/Apps/wordle/wordle.py :

 

Option for using mypy instead of dmypy (daemon)

Suggestion

Currently, a number of features are buggy or unsupported when using dmypy instead of calling the mypy command directly.

I am aware you can sort-of achieve this by setting the mypy-typer-checker.path to mypy, but it would be nice to be able to use the same mechanisms for using the chosen interpreter and and discovered mypy version (via "fromEnvironment" / "useBundled"), as seen here: https://github.com/microsoft/vscode-mypy/blob/main/bundled/tool/lsp_server.py#L557-L561

I imagine a setting like useDaemon which defaults to true. If set to false, and path not set, it would run the same logic as for the daemon, but calling the mypy module instead.

squiggles are one character too short.

The error squiggles seem to always be one character off.

Example:

def foo(x: int) -> int:
    return x + 1


foo("some string")

The error squiggles are one character too short.
image

errors appearing in the wrong files

Error locations are all over the place, see:
image
image

I have restarted mypy server, reloaded window, closed and re-opened vscode, somehow it keeps getting worse.
For example, now it's
image

Python 3.9.13
mypy 1.4.1 (compiled: yes)
ms-python.mypy-type-checker: v2023.1.11781017

Allow excluding 3rd party code

I have a submodule checked out in my repository and mypy is peppering it in errors and I don't seem to be able to find a way to exclude it. Strangely, when I visit python files in my venv, they don't get any errors (even if they have the same issue present in the file), so there must be some exclusion applied for those kinds of files by the extension.

I've tried using mypy.ini but as VSCode invokes mypy on the file itself, I still receive errors from this extension.

I'd like mypy to treat the submodule like it treats files in the venv... what's the recommended approach here?

Feature request: Link to the error's documentation

I would like for the error info popup to also link to the appropriate error code documentation. For example no-untyped-def would link to https://mypy.readthedocs.io/en/stable/error_code_list2.html#check-that-every-function-has-an-annotation-no-untyped-def . Similarly to how ESLint and Pylance do it:
image
image

I found that it is an extremely powerful tool for learning and help devs understand the errors. Especially newer developers who are less keen to go dig up documentation they don't even know if it exists.

`mypy.args` does not work

Screenshot 2023-05-28 at 12 04 46 PM

mypy.args is not recognized, despite its mention in the README. Upon further investigation, no mypy configurations are available.

Error when using `mypy==1.5.0`

When using mypy==1.5.0 (from environment), the following error occurs:

mypy: error: ambiguous option: --show-error-code could match --show-error-codes, --show-error-code-links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.