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

ignorePatterns setting not considered for non-workspace files #326

Closed
taesungh opened this issue Aug 15, 2024 · 0 comments · Fixed by #327
Closed

ignorePatterns setting not considered for non-workspace files #326

taesungh opened this issue Aug 15, 2024 · 0 comments · Fixed by #327
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed

Comments

@taesungh
Copy link
Contributor

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:

  1. Open a new Code window without opening a folder or workspace
  2. Add a pattern to the user settings for flake8.ignorePatterns, e.g. "*.py"
  3. Open a Python file that is not in the workspace but matches the pattern to be ignored
  4. Add some code that violates a lint rule, e.g. an unused import
  5. Observe that linting still runs on the file even though it should be ignored
  6. Open the folder containing the file in the Code window
  7. Observe that the pattern causes linting to be skipped ("Skipping file due to flake8.ignorePatterns match")
VS Code window showing a problem reported by Flake8 even though the file matches an ignore pattern in the user settings

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.

"ignorePatterns": [],
"importStrategy": GLOBAL_SETTINGS.get("importStrategy", "useBundled"),
"showNotifications": GLOBAL_SETTINGS.get("showNotifications", "off"),

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

Successfully merging a pull request may close this issue.

1 participant