Skip to content

Comments

Fix stdlib detection incorrectly flagging site-packages files#385

Draft
Copilot wants to merge 9 commits intomainfrom
copilot/fix-skipping-notification-bug
Draft

Fix stdlib detection incorrectly flagging site-packages files#385
Copilot wants to merge 9 commits intomainfrom
copilot/fix-skipping-notification-bug

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Users receive "Skipping standard library file (stdlib excluded)" notifications for third-party packages in site-packages (e.g., pytest, numpy), which are not stdlib files.

Root Cause

_stdlib_paths incorrectly included:

  • site.getsitepackages() / site.getusersitepackages() - third-party package directories
  • purelib/platlib from sysconfig.get_paths() - also site-packages paths

Changes

bundled/tool/lsp_utils.py:

  • _get_sys_config_paths(): Only include stdlib and platstdlib from sysconfig.get_paths()
  • _stdlib_paths: Remove site.getsitepackages() and site.getusersitepackages()
  • is_stdlib_file(): Add explicit exclusion for paths containing {os.sep}site-packages{os.sep} or {os.sep}dist-packages{os.sep} to handle edge cases

src/test/python_tests/test_stdlib_detection.py:

  • New test suite validating stdlib vs site-packages detection
  • Includes path segment matching validation (e.g., site-packages-backupsite-packages)

Example

# Before: incorrectly detected as stdlib
is_stdlib_file("/usr/lib/python3.12/site-packages/pytest/__init__.py")  # True ❌

# After: correctly identified as third-party
is_stdlib_file("/usr/lib/python3.12/site-packages/pytest/__init__.py")  # False ✓
is_stdlib_file("/usr/lib/python3.12/os.py")  # True ✓
Original prompt

This section details on the original issue you should resolve

<issue_title>Skipping standard library file notification</issue_title>
<issue_description><!-- Hello! Thank you for submitting a bug to our repo. Our users and their bug reports are essential to our development process.
Before you submit an issue:

  1. Please search for the bug in existing issues on the repo. Search using keywords or error messages and check both open and closed issues.
  2. Try setting your log level to trace and look at the logs in more detail, as there may be more information there. If not, then these trace logs are part
    of the bug report below! (see directions on how to set and access these logs in the Logs section below.)
    Thank you!-->

Diagnostic Data

  • Python version (& distribution if applicable, e.g., Anaconda): 3.13
  • Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): venv
  • Operating system (and version): Windows 11 Enterprise 10.0.26200
  • Version of tool extension you are using: 2025.2.0

Behaviour

Expected Behavior

No notifications during normal use.

Actual Behavior

Repeated 'Skipping standard library file (stdlib excluded)' notifications with a path pointing to site-packages.

Image

Reproduction Steps:

I don't think I've done anything special, I have a venv (created using python -m venv <path>) activated and write code. The latest notification that showed up today was for monkeypatch, so maybe writing a pytest test using monkeypatch. Importantly, I did not open any file in site-packages.

Logs:

Unfortunately the logs include sensitive client information. I have included a redacted version (mostly removing filenames/paths).

Click here for detailed logs 2025-12-02 12:04:43.949 [info] [Trace - 12:04:43 PM] Sending request 'textDocument/codeAction - (1451)'. 2025-12-02 12:04:43.949 [info] Params: { "textDocument": { "uri": "--redacted--" }, "range": { "start": { "line": 32, "character": 0 }, "end": { "line": 40, "character": 0 } }, "context": { "diagnostics": [], "triggerKind": 2 } }

2025-12-02 12:04:43.952 [info] [Trace - 12:04:43 PM] Received response 'textDocument/codeAction - (1451)' in 3ms.
2025-12-02 12:04:43.952 [info] Result: []

2025-12-02 12:04:45.241 [info] [Trace - 12:04:45 PM] Sending notification 'textDocument/didChange'.
2025-12-02 12:04:45.241 [info] Params: {
"textDocument": {
"uri": "--redacted--",
"version": 3281
},
"contentChanges": [
{
"range": {
"start": {
"line": 32,
"character": 0
},
"end": {
"line": 40,
"character": 0
}
},
"rangeLength": 199,
"text": ""
}
]
}

2025-12-02 12:04:47.077 [info] [Trace - 12:04:47 PM] Sending notification 'textDocument/didOpen'.
2025-12-02 12:04:47.077 [info] Params: {
"textDocument": {
"uri": "file:///c%3A/--venv path--/Lib/site-packages/pytest_bdd/steps.py",
"languageId": "python",
"version": 1,
"text": """"Step decorators.\n\nExample:\n\n@given("I have an article", target_fixture="article")\ndef _(author):\n return create_test_article(author=author)\n\n\n@when("I go to the article page")\ndef _(browser, article):\n browser.visit(urljoin(browser.url, "/articles/{0}/".format(article.id)))\n\n\n@then("I should not see the error message")\ndef _(browser):\n with pytest.raises(ElementDoesNotExist):\n browser.find_by_css(".message.error").first\n\n\nMultiple names for the steps:\n\n@given("I have an article")\n@given("there is an article")\ndef _(author):\n return create_test_article(author=author)\n\n\nReusing existing fixtures for a different step name:\n\n\n@given("I have a beautiful article")\ndef _(article):\n pass\n\n"""\n\nfrom future import annotations\n\nimport enum\nfrom collections.abc import Iterable\nfrom dataclasses import dataclass, field\nfrom itertools import count\nfrom typing import Any, Callable, Literal, TypeVar\n\nimport pytest\nfrom typing_extensions import ParamS...


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 8 commits February 18, 2026 01:59
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
…false positive test

Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
…in tests

Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug for skipping standard library file notification Fix stdlib detection incorrectly flagging site-packages files Feb 18, 2026
Copilot AI requested a review from edvilme February 18, 2026 02:10
Copy link

@rchiodo rchiodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skipping standard library file notification

3 participants