The values in the ignorePatterns setting is not considered for files not in the current workspace.
Diagnostic Data
Python version: 3.12.4
Type of virtual environment used: none
Operating system: macOS 12.6.9
Version of tool extension you are using: Flake8 v2023.10.0
Behaviour
The patterns work for files in the workspace but not those outside.
Expected Behavior
A pattern specified in the flake8.ignorePatterns setting for the user (or remote) should be considered for any open file, either part of the workspace or not.
Actual Behavior
The patterns are not considered for files outside of the current workspace.
Reproduction Steps:
Open a new Code window without opening a folder or workspace
Add a pattern to the user settings for flake8.ignorePatterns, e.g. "*.py"
Open a Python file that is not in the workspace but matches the pattern to be ignored
Add some code that violates a lint rule, e.g. an unused import
Observe that linting still runs on the file even though it should be ignored
Open the folder containing the file in the Code window
Observe that the pattern causes linting to be skipped ("Skipping file due to flake8.ignorePatterns match")
Extra Details
My use case for this is related to a separate problem with detecting libraries in site-packages for which I'll submit a separate issue.
The culprit here seems to be lsp_server._get_global_defaults which does not check GLOBAL_SETTINGS for a default value unlike all other extension settings. This function is called by _get_settings_by_document when a file not in the workspace does not have a document key. Assuming this is just an oversight and not intentional, the fix should be fairly simple.
The values in the
ignorePatterns
setting is not considered for files not in the current workspace.Diagnostic Data
Behaviour
The patterns work for files in the workspace but not those outside.
Expected Behavior
A pattern specified in the
flake8.ignorePatterns
setting for the user (or remote) should be considered for any open file, either part of the workspace or not.Actual Behavior
The patterns are not considered for files outside of the current workspace.
Reproduction Steps:
flake8.ignorePatterns
, e.g."*.py"
flake8.ignorePatterns
match")Extra Details
My use case for this is related to a separate problem with detecting libraries in site-packages for which I'll submit a separate issue.
The culprit here seems to be
lsp_server._get_global_defaults
which does not checkGLOBAL_SETTINGS
for a default value unlike all other extension settings. This function is called by_get_settings_by_document
when a file not in the workspace does not have a document key. Assuming this is just an oversight and not intentional, the fix should be fairly simple.https://github.com/microsoft/vscode-flake8/blob/815cd6865364dba6cfd23aa05201d5423781d9fb/bundled/tool/lsp_server.py#L466-L468