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

Ambiguous option --show-error-code #125

Closed
markedwards opened this issue Aug 26, 2023 · 6 comments
Closed

Ambiguous option --show-error-code #125

markedwards opened this issue Aug 26, 2023 · 6 comments

Comments

@markedwards
Copy link

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.

@markedwards
Copy link
Author

markedwards commented Aug 26, 2023

I am able to get it working by setting this instead: "python.defaultInterpreterPath": "/venv/bin/python".

Should the extension be capable of finding /venv/bin/dmypy and using that when "fromEnvironment" is used? That's what I'm hoping for.

Incidentally, I get no error output at all with the default settings, on a trivial example:

def test() -> str:
    return 0

The only success I've had is with "python.defaultInterpreterPath": "/venv/bin/python".

@kvitek
Copy link

kvitek commented Aug 28, 2023

I think it is real issue because mypy doesn't have --show-error-code option, it has --show-error-codes option. 1.4.1 version of mypy has only one option starts with --show-error-code so it's fallback to --show-error-codes automatically. But version 1.5.1 has also --show-error-code-links option and mypy could not choose correct fallback, so the error is raising and type checking is stopping.

@karthiknadig
Copy link
Member

@markedwards This is addressed in the pre-release version.

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2023
@markedwards
Copy link
Author

markedwards commented Aug 28, 2023

Yes, I can confirm things are working with the pre-release version. The issue I was having with running the bundled version was an error related to follow_imports = "silent" in pyproject.toml, but I don't actually need that setting anyway. And I prefer to run mypy from the environment anyway.

Now the only issue I see is that type errors in VSCode seem to persist even after they are fixed. Will open a separate ticket for that.

@markedwards
Copy link
Author

Actually, I now see that the current release seems broken regardless of my pyproject.toml, due to:

2023-08-28 20:24:52.516 [info] Using legacy Mypy args from 'python.linting.mypyArgs': --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty.
...
2023-08-28 20:25:03.793 [info] /venv/bin/python -m mypy.dmypy --status-file /tmp/.vscode.dmypy_status/status-bd28a0e4-1e23-4e12-8ddd-908f93011c58.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 /email-assistant/temp.py
2023-08-28 20:25:04.113 [info] [Trace - 8:25:04 PM] Received notification 'window/logMessage'.
2023-08-28 20:25:04.114 [info] dmypy: follow-imports=silent not supported

@kvitek
Copy link

kvitek commented Aug 29, 2023

There is more clear way to add any option to mypy daemon. Just create mypy.ini file doc and pass it as args in settings.json "mypy-type-checker.args": ["--config", "mypy.ini"]. It will give you flexible way to control which code must be type checked. Using --follow-imports=silent is not recommended by official doc

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

3 participants