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

Can't figure out how to configure extension to allow for gradual adoption #304

Closed
jrheard opened this issue May 30, 2024 · 10 comments
Closed
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed

Comments

@jrheard
Copy link

jrheard commented May 30, 2024

Context

I'm trying to figure out how to configure both Mypy and the Mypy vscode extension to only run on files in one or two directories in my codebase. I'm introducing mypy to a preexisting long-lived project, and want to adopt it gradually.

(I'm providing a minimal repro repo, and I'm only talking about wanting to run on one or two specified directories, but please imagine that soon I'll want to run on fifteen or twenty directories that are nested arbitrarily deep into the real-life repo that I'm trying to introduce mypy to. It will be a long time (if ever) before I'm able to run mypy on an entire nontrivial top-level directory in this real-life repo.)

I'm sure that I must be doing something wrong and am hopeful that there's some easy obvious combination of configuration options that will provide the behavior that I want, but I've spent a fair amount of time trying to figure this out and haven't gotten anywhere. Thanks in advance :)

(I've tried the file and workspace reporting scopes and haven't seen a difference in the resulting behavior, fwiw)

Diagnostic Data

  • Python version (& distribution if applicable, e.g., Anaconda): 3.12.3
  • Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): poetry
  • Operating system (and version): macOS Sonoma 14.5
  • Version of tool extension you are using: v2023.6.0

Behaviour

Expected Behavior

I should be able to use a combination of mypy.ini configuration options and vscode mypy extension settings in order to get the vscode extension to only run on file vscode_mypy_repro/b/good/*.py in https://github.com/jrheard/vscode_mypy_repro .

Actual Behavior

When I run mypy at the command line, it only runs on the files that I want it to (which is good!). But when I edit other files (eg vscode_mypy_repro/a/one.py) in vscode, the vscode mypy extension runs on those files too, and shows type errors in those files even though I don't want to see them because I haven't added them to my allow list of files yet.

Reproduction Steps:

  1. Clone https://github.com/jrheard/vscode_mypy_repro
  2. run poetry install (or just use your global mypy, I don't think this matters)
  3. run poetry run mypy (or just mypy) with no args and see that it only runs on vscode_mypy_repro/b/good/example.py (which is good!)
  4. open vscode_mypy_repro/a/one.py in vscode with the mypy extension installed, edit the file, and see a type error displayed in the vscode editor (this is not what I want, I only want the vscode extension to run on certain allowlisted files/directories)

Question: Is there some combination of mypy.ini settings and vscode settings that will make it so that both command-line mypy and the vscode extension only typecheck files in the vscode_mypy_repro/b directory? Ideally this would be achievable using only mypy.ini settings so that CI and vscode are both reading from the same place with no further per-developer-machine configuration necessary, but vscode settings are OK if necessary.

Thank you!

Logs:

Click here for detailed logs (reporting scope: workspace) 2024-05-29 20:02:33.493 [info] [Trace - 8:02:33 PM] Sending notification 'textDocument/didChange'. 2024-05-29 20:02:33.494 [info] Params: { "textDocument": { "uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py", "version": 8 }, "contentChanges": [ { "range": { "start": { "line": 2, "character": 0 }, "end": { "line": 2, "character": 0 } }, "rangeLength": 0, "text": "\n" } ] }

2024-05-29 20:02:39.426 [info] [Trace - 8:02:39 PM] Sending notification 'textDocument/didChange'.
2024-05-29 20:02:39.426 [info] Params: {
"textDocument": {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py",
"version": 9
},
"contentChanges": [
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 3,
"character": 0
}
},
"rangeLength": 1,
"text": ""
}
]
}

2024-05-29 20:02:39.446 [info] [Trace - 8:02:39 PM] Sending notification 'textDocument/didSave'.
2024-05-29 20:02:39.446 [info] Params: {
"textDocument": {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py"
}
}

2024-05-29 20:02:39.448 [info] /Users/jrheard/.vscode/extensions/ms-python.mypy-type-checker-2023.6.0/bundled/tool/lsp_server.py:172: DeprecationWarning: 'workspace.get_document' has been deprecated, use 'workspace.get_text_document' instead
document = LSP_SERVER.workspace.get_document(params.text_document.uri)

2024-05-29 20:02:39.448 [info] [Trace - 8:02:39 PM] Received notification 'window/logMessage'.
2024-05-29 20:02:39.448 [info] Params: {
"type": 4,
"message": "/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/.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 /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro"
}

2024-05-29 20:02:39.449 [info] /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/.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 /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro
2024-05-29 20:02:39.449 [info] [Trace - 8:02:39 PM] Received notification 'window/logMessage'.
2024-05-29 20:02:39.449 [info] Params: {
"type": 4,
"message": "CWD Server: /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro"
}

2024-05-29 20:02:39.449 [info] CWD Server: /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro
2024-05-29 20:02:39.804 [info] [Trace - 8:02:39 PM] Received notification 'window/logMessage'.
2024-05-29 20:02:39.804 [info] Params: {
"type": 4,
"message": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :\r\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/c/three.py:3:5:3:12: error: No return value expected [return-value]\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/two.py:2:5:2:12: error: No return value expected [return-value]\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/good/example.py:2:5:2:12: error: No return value expected [return-value]\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py:2:5:2:12: error: No return value expected [return-value]\n"
}

2024-05-29 20:02:39.804 [info] file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/c/three.py:3:5:3:12: error: No return value expected [return-value]
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/two.py:2:5:2:12: error: No return value expected [return-value]
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/good/example.py:2:5:2:12: error: No return value expected [return-value]
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py:2:5:2:12: error: No return value expected [return-value]

2024-05-29 20:02:39.804 [info] [Trace - 8:02:39 PM] Received notification 'window/logMessage'.
2024-05-29 20:02:39.804 [info] Params: {
"type": 4,
"message": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :\r\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/c/three.py:3:5:3:12: error: No return value expected [return-value]\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/two.py:2:5:2:12: error: No return value expected [return-value]\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/good/example.py:2:5:2:12: error: No return value expected [return-value]\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py:2:5:2:12: error: No return value expected [return-value]\n"
}

2024-05-29 20:02:39.804 [info] file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/c/three.py:3:5:3:12: error: No return value expected [return-value]
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/two.py:2:5:2:12: error: No return value expected [return-value]
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/good/example.py:2:5:2:12: error: No return value expected [return-value]
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py:2:5:2:12: error: No return value expected [return-value]

2024-05-29 20:02:39.805 [info] [Trace - 8:02:39 PM] Received notification 'textDocument/publishDiagnostics'.
2024-05-29 20:02:39.805 [info] Params: {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/c/three.py",
"diagnostics": [
{
"range": {
"start": {
"line": 2,
"character": 4
},
"end": {
"line": 2,
"character": 12
}
},
"message": "No return value expected",
"severity": 1,
"code": "return-value",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-return-value"
},
"source": "Mypy"
}
]
}

2024-05-29 20:02:39.805 [info] [Trace - 8:02:39 PM] Received notification 'textDocument/publishDiagnostics'.
2024-05-29 20:02:39.805 [info] Params: {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/two.py",
"diagnostics": [
{
"range": {
"start": {
"line": 1,
"character": 4
},
"end": {
"line": 1,
"character": 12
}
},
"message": "No return value expected",
"severity": 1,
"code": "return-value",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-return-value"
},
"source": "Mypy"
}
]
}

2024-05-29 20:02:39.805 [info] [Trace - 8:02:39 PM] Received notification 'textDocument/publishDiagnostics'.
2024-05-29 20:02:39.805 [info] Params: {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/b/good/example.py",
"diagnostics": [
{
"range": {
"start": {
"line": 1,
"character": 4
},
"end": {
"line": 1,
"character": 12
}
},
"message": "No return value expected",
"severity": 1,
"code": "return-value",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-return-value"
},
"source": "Mypy"
}
]
}

2024-05-29 20:02:39.805 [info] [Trace - 8:02:39 PM] Received notification 'textDocument/publishDiagnostics'.
2024-05-29 20:02:39.805 [info] Params: {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py",
"diagnostics": [
{
"range": {
"start": {
"line": 1,
"character": 4
},
"end": {
"line": 1,
"character": 12
}
},
"message": "No return value expected",
"severity": 1,
"code": "return-value",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-return-value"
},
"source": "Mypy"
}
]
}

Click here for detailed logs (reporting scope: file) 2024-05-29 20:03:23.737 [info] [Trace - 8:03:23 PM] Sending notification 'textDocument/didChange'. 2024-05-29 20:03:23.737 [info] Params: { "textDocument": { "uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py", "version": 10 }, "contentChanges": [ { "range": { "start": { "line": 2, "character": 0 }, "end": { "line": 2, "character": 0 } }, "rangeLength": 0, "text": "\n" } ] }

2024-05-29 20:03:24.556 [info] [Trace - 8:03:24 PM] Sending notification 'textDocument/didChange'.
2024-05-29 20:03:24.556 [info] Params: {
"textDocument": {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py",
"version": 11
},
"contentChanges": [
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 3,
"character": 0
}
},
"rangeLength": 1,
"text": ""
}
]
}

2024-05-29 20:03:24.581 [info] [Trace - 8:03:24 PM] Sending notification 'textDocument/didSave'.
2024-05-29 20:03:24.582 [info] Params: {
"textDocument": {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py"
}
}

2024-05-29 20:03:24.583 [info] /Users/jrheard/.vscode/extensions/ms-python.mypy-type-checker-2023.6.0/bundled/tool/lsp_server.py:172: DeprecationWarning: 'workspace.get_document' has been deprecated, use 'workspace.get_text_document' instead
document = LSP_SERVER.workspace.get_document(params.text_document.uri)

2024-05-29 20:03:24.584 [info] [Trace - 8:03:24 PM] Received notification 'window/logMessage'.
2024-05-29 20:03:24.584 [info] Params: {
"type": 4,
"message": "/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/.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 /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py"
}

2024-05-29 20:03:24.584 [info] /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/.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 /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py
2024-05-29 20:03:24.584 [info] [Trace - 8:03:24 PM] Received notification 'window/logMessage'.
2024-05-29 20:03:24.584 [info] Params: {
"type": 4,
"message": "CWD Server: /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro"
}

2024-05-29 20:03:24.584 [info] CWD Server: /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro
2024-05-29 20:03:25.056 [info] [Trace - 8:03:25 PM] Received notification 'window/logMessage'.
2024-05-29 20:03:25.057 [info] Params: {
"type": 4,
"message": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :\r\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py:2:5:2:12: error: No return value expected [return-value]\n"
}

2024-05-29 20:03:25.057 [info] file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py:2:5:2:12: error: No return value expected [return-value]

2024-05-29 20:03:25.057 [info] [Trace - 8:03:25 PM] Received notification 'window/logMessage'.
2024-05-29 20:03:25.057 [info] Params: {
"type": 4,
"message": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :\r\n/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py:2:5:2:12: error: No return value expected [return-value]\n"
}

2024-05-29 20:03:25.057 [info] file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :
/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py:2:5:2:12: error: No return value expected [return-value]

2024-05-29 20:03:25.057 [info] [Trace - 8:03:25 PM] Received notification 'textDocument/publishDiagnostics'.
2024-05-29 20:03:25.057 [info] Params: {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py",
"diagnostics": [
{
"range": {
"start": {
"line": 1,
"character": 4
},
"end": {
"line": 1,
"character": 12
}
},
"message": "No return value expected",
"severity": 1,
"code": "return-value",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-return-value"
},
"source": "Mypy"
}
]
}

Outcome When Attempting Debugging Steps:

Did running it from the command line work?

Running poetry run mypy --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-error-en d /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro (which is what the extension runs with reportingScope: workspace, with poetry run prefixed) runs mypy on the whole repo, which is not what I want. I'd like to figure out how to configure this command so that the extension and the default command-line mypy tool both only operate on one or two specified directories in the whole repo.

@jrheard jrheard added the bug Issue identified by VS Code Team member as probable bug label May 30, 2024
@karthiknadig
Copy link
Member

@jrheard Have you looked into setting mypy-type-checker.ignorePatterns to help with this? This will work with scope file.

@jrheard
Copy link
Author

jrheard commented May 30, 2024

Hey @karthiknadig , thanks for the speedy response! The behavior I'm looking for would look something like this:

  1. I use mypy-type-checker.ignorePatterns to ignore the whole repo
  2. I use some equivalent of mypy-type-checker.allowPatterns to specify that I only want to have the extension type check directories foo/bar/, foo/baz/quux/, and some/deeply/nested/dir/. This second setting would effectively partially override the ignorePatterns setting.

To put it another way, it's not the case that I want to type check the whole repo and only ignore messages for certain directories - instead I only want to type check certain deeply nested directories (eg some/deeply/nested/dir/), and they may be contained within other directories whose other contents I want to ignore (eg everything else in some/deeply/nested/, including some/deeply/nested/other_dir/, some/deeply/a_file.py, etc etc).

Is this possible? Please let me know if this doesn't make sense. I think that the behavior I'm looking for is reasonable, but it's always possible that I'm coming at this from a confused/incorrect starting point. Thanks!

jrheard added a commit to jrheard/vscode-mypy that referenced this issue May 30, 2024
@jrheard
Copy link
Author

jrheard commented May 30, 2024

I think that this is a sketch of what I have in mind: 1d15b7c .

(I just put this together in ten seconds as an illustration after a quick search through the codebase for usage of ignorePatterns - this is obviously not a fully-fledged PR, just an example of the behavior I'm hoping to accomplish here, hopefully with preexisting configuration options).

Again, the best outcome for me here would be for this behavior to be configurable solely through mypy.ini, because I'd prefer to not have to tell all of my coworkers that we have to keep our mypy extension settings in sync with mypy.ini as that file changes over time (as we hopefully add more and more directories to our allowlist). Ideally CI and vscode would be running mypy using the same configuration options with no duplication / potential for drift.

@karthiknadig
Copy link
Member

Were you not able to set a pattern with: https://mypy.readthedocs.io/en/stable/config_file.html#confval-exclude

Looking at mypy.ini here I did not see an exclude pattern.
image

I think you should be able to use exclude pattern in mypy.ini and use workspace scope to make this work. Workspace scope just runs on workspace as the target (which is what you would do in CI), so adding exclude patterns in mypy.ini should make it ignore the paths.

@jrheard
Copy link
Author

jrheard commented May 30, 2024

Thanks, I bet that's the ticket. I had a hard time figuring out how to come up with the right combination of mypy.ini options to get the behavior that I want, but I'm sure that it should be achievable (I think I did this at a past job several years ago, but I don't remember how). FWIW, when I try this:

[mypy]
strict = True
exclude = .*.py
files = vscode_mypy_repro/b/good/*.py

I get this:

🚂  poetry run mypy --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-error-en
d /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro
There are no .py[i] files in directory '/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro'

But that's a question I should ask the mypy folks rather than you, and again I'm sure I'm missing something obvious here.

If I'm hearing you correctly, then once I get my mypy.ini configured the way I want, workspace scope should do exactly what I need, because it sounds like workspace scope uses mypy.ini in exactly the way that I was hoping for. Thanks for your help, feel free to close the issue!

@jrheard
Copy link
Author

jrheard commented May 30, 2024

Whoops, I spoke too soon! It looks like I get different output when I run mypy directly at the command line:

[jrheard@erebus:vscode_mypy_repro]  main [!] took 6s 412ms 
🚂  poetry run mypy --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-error-en
d /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro
There are no .py[i] files in directory '/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro'

[jrheard@erebus:vscode_mypy_repro]  main [!] 
🚂  poetry run mypy
vscode_mypy_repro/b/good/example.py:2: error: No return value expected  [return-value]
Found 1 error in 1 file (checked 2 source files)

It looks like the command-line mypy gives me the behavior I want, but the vscode extension invocation of mypy doesn't. Logs here:

Click 2024-05-29 21:12:50.541 [info] [Trace - 9:12:50 PM] Sending notification 'textDocument/didChange'. 2024-05-29 21:12:50.541 [info] Params: { "textDocument": { "uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py", "version": 14 }, "contentChanges": [ { "range": { "start": { "line": 2, "character": 0 }, "end": { "line": 2, "character": 0 } }, "rangeLength": 0, "text": "\n" } ] }

2024-05-29 21:12:51.204 [info] [Trace - 9:12:51 PM] Sending notification 'textDocument/didChange'.
2024-05-29 21:12:51.204 [info] Params: {
"textDocument": {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py",
"version": 15
},
"contentChanges": [
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 3,
"character": 0
}
},
"rangeLength": 1,
"text": ""
}
]
}

2024-05-29 21:12:51.226 [info] [Trace - 9:12:51 PM] Sending notification 'textDocument/didSave'.
2024-05-29 21:12:51.226 [info] Params: {
"textDocument": {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py"
}
}

2024-05-29 21:12:51.228 [info] [Trace - 9:12:51 PM] Received notification 'window/logMessage'.
2024-05-29 21:12:51.228 [info] Params: {
"type": 4,
"message": "/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/.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 /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro"
}

2024-05-29 21:12:51.228 [info] /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/.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 /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro
2024-05-29 21:12:51.228 [info] [Trace - 9:12:51 PM] Received notification 'window/logMessage'.
2024-05-29 21:12:51.228 [info] Params: {
"type": 4,
"message": "CWD Server: /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro"
}

2024-05-29 21:12:51.228 [info] CWD Server: /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro
2024-05-29 21:12:51.358 [info] [Trace - 9:12:51 PM] Received notification 'window/logMessage'.
2024-05-29 21:12:51.358 [info] Params: {
"type": 4,
"message": "There are no .py[i] files in directory '/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro'\n"
}

2024-05-29 21:12:51.358 [info] There are no .py[i] files in directory '/Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro'

2024-05-29 21:12:51.358 [info] [Trace - 9:12:51 PM] Received notification 'window/logMessage'.
2024-05-29 21:12:51.358 [info] Params: {
"type": 4,
"message": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :\r\n"
}

2024-05-29 21:12:51.358 [info] file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py :

2024-05-29 21:12:51.358 [info] [Trace - 9:12:51 PM] Received notification 'textDocument/publishDiagnostics'.
2024-05-29 21:12:51.358 [info] Params: {
"uri": "file:///Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro/vscode_mypy_repro/a/one.py",
"diagnostics": []
}

@karthiknadig
Copy link
Member

I would need to look at the settings, and also the mypy version in CLI and the one run by internal might be different. You should be able to see the shipped version at the top of the logs.

@jrheard
Copy link
Author

jrheard commented May 30, 2024

It looks like it's using version 1.10 if I'm reading this right 👍

I think that I need to quit bugging you for a bit and go figure out how to configure mypy.ini so that poetry run mypy /Users/jrheard/Library/CloudStorage/Dropbox/dev/vscode_mypy_repro gives the output that I'm looking for. Sorry for all the comments and edits, I clearly need to spend some more time debugging this myself for now. Thanks again, I very much appreciate your time!

@jrheard jrheard closed this as completed May 30, 2024
@karthiknadig
Copy link
Member

This looks like something to ask mypy devs about:
image

basically, the pattern applies correctly when you run it without a specific folder path, but fails to apply when you do run it with a folder path. When technically both are the same location.

@jrheard
Copy link
Author

jrheard commented May 30, 2024

Good call - I asked in the mypy gitter, but kept poking around in the meantime, and I think I found the solution. This mypy.ini seems to do the trick:

[mypy]
ignore_errors = True

[mypy-vscode_mypy_repro.b.good.*]
ignore_errors = False
strict = True

I knew there was some setting like this that I used at my last job, and I spent a lot of time with the mypy.ini docs today trying to jog my memory; I must have accidentally skipped over the ignore_errors documentation seven or eight times, whoops.

With this mypy.ini and reportingScope: workspace, I get the behavior I wanted: the vscode mypy extension typechecks vscode_mypy_repo/b/good/example.py, but it ignores all other files including e.g. a/one.py. Success! Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed
Projects
None yet
Development

No branches or pull requests

2 participants