Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
aaronsgithub opened this issue Aug 13, 2023 · 2 comments

Comments

@aaronsgithub
Copy link

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.

@aaronsgithub
Copy link
Author

aaronsgithub commented Aug 13, 2023

I just found that there you have to enable linting in the Python extension, and set the default linter to mypy.

I think some notes explaining this in the docs would help users get started.

You might also want to ensure Pylance linting is turned off as you could see duplicate reporting of errors.

@karthiknadig
Copy link
Member

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.

This is due to a bug is dmypy python/mypy#15677

I just found that there you have to enable linting in the Python extension, and set the default linter to mypy.

With this extension, you don't have to enable anything. The reason it did not work for you is due to a bug in mypy itself. I will be adding a setting to allow switching between the mypy and dmypy see here #115 . dmypy was chosen as it is designed to be performant, but it seems to be still buggy.

Closing this against #115

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants