Skip to content

pylance sometimes looks into excluded folders like "~/.pyenv" #7204

Description

@ilyakochik

Type: Bug

Behaviour

Sometimes pylance reports a ton of issues in ~/.pyenv files like functools. This appears and disappears for no reason.

For example this is Problems tab:

[{
	"resource": "/Users/ilyakochik/.pyenv/versions/3.12.7/lib/python3.12/functools.py",
	"owner": "python",
	"code": {
		"value": "reportAssignmentType",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportAssignmentType"
		}
	},
	"severity": 8,
	"message": "Type \"None\" is not assignable to declared type \"(self: Self@object) -> int\"\n  Type \"None\" is not assignable to type \"(self: Self@object) -> int\"",
	"source": "Pylance",
	"startLineNumber": 222,
	"startColumn": 20,
	"endLineNumber": 222,
	"endColumn": 24
},{
	"resource": "/Users/ilyakochik/.pyenv/versions/3.12.7/lib/python3.12/functools.py",
	"owner": "python",
	"code": {
		"value": "reportMissingImports",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportMissingImports"
		}
	},
	"severity": 8,
	"message": "Import \"_functools\" could not be resolved",
	"source": "Pylance",
	"startLineNumber": 226,
	"startColumn": 10,
	"endLineNumber": 226,
	"endColumn": 20
},{
	"resource": "/Users/ilyakochik/.pyenv/versions/3.12.7/lib/python3.12/functools.py",
	"owner": "python",
	"code": {
		"value": "reportMissingImports",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportMissingImports"
		}
	},
	"severity": 8,
	"message": "Import \"_functools\" could not be resolved",
	"source": "Pylance",
	"startLineNumber": 266,
	"startColumn": 10,
	"endLineNumber": 266,
	"endColumn": 20
},{
	"resource": "/Users/ilyakochik/.pyenv/versions/3.12.7/lib/python3.12/functools.py",
	"owner": "python",
	"code": {
		"value": "reportMissingImports",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportMissingImports"
		}
	},
	"severity": 8,
	"message": "Import \"_functools\" could not be resolved",
	"source": "Pylance",
	"startLineNumber": 342,
	"startColumn": 10,
	"endLineNumber": 342,
	"endColumn": 20
},{
	"resource": "/Users/ilyakochik/.pyenv/versions/3.12.7/lib/python3.12/functools.py",
	"owner": "python",
	"code": {
		"value": "reportAttributeAccessIssue",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportAttributeAccessIssue"
		}
	},
	"severity": 8,
	"message": "Cannot assign to attribute \"__self__\" for class \"partial\"\n  Attribute \"__self__\" is unknown",
	"source": "Pylance",
	"startLineNumber": 401,
	"startColumn": 28,
	"endLineNumber": 401,
	"endColumn": 36
},{
	"resource": "/Users/ilyakochik/.pyenv/versions/3.12.7/lib/python3.12/functools.py",
	"owner": "python",
	"code": {
		"value": "reportMissingImports",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportMissingImports"
		}
	},
	"severity": 8,
	"message": "Import \"_functools\" could not be resolved",
	"source": "Pylance",
	"startLineNumber": 640,
	"startColumn": 10,
	"endLineNumber": 640,
	"endColumn": 20
},{
	"resource": "/Users/ilyakochik/.pyenv/versions/3.12.7/lib/python3.12/functools.py",
	"owner": "python",
	"code": {
		"value": "reportArgumentType",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportArgumentType"
		}
	},
	"severity": 8,
	"message": "Argument of type \"None\" cannot be assigned to parameter \"maxsize\" of type \"int\" in function \"lru_cache\"\n  \"None\" is not assignable to \"int\"",
	"source": "Pylance",
	"startLineNumber": 651,
	"startColumn": 30,
	"endLineNumber": 651,
	"endColumn": 34
}]

while this is .vscode/settings.json:

{
  // Python testing
  "python.testing.unittestEnabled": false,
  "python.testing.pytestEnabled": true,
  "python.testing.pytestArgs": ["--quiet", "--tb=short"],

  // Python linting
  "python.analysis.typeCheckingMode": "basic",
  "python.analysis.exclude": ["**/.venv", "**/.pyenv", "~/.pyenv"],

  // VSCode file explorer
  "files.exclude": {
    "**/.conda": true,
    "**/__pycache__": true,
    "**/.pytest_cache": true,
    "**/.venv": true,
    "**/node_modules": true,
    "out": false,
    "dist": false
  },
  "search.exclude": {
    "out": true,
    "dist": true
  },

  // Formatting
  "black-formatter.args": ["-l", "120"],
  "typescript.tsc.autoDetect": "off",
  "prettier.printWidth": 120,
  "prettier.semi": true,
  "prettier.proseWrap": "always"
}

Steps to reproduce:

I don't know why it happens some times and not the others. It appears and disappears with no trigger. After I finished reporting the issue all Problems disappeared.

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Python output is quite unhelpful

2025-05-11 15:14:10.134 [info] Discover tests for workspace name: sql-refining - uri: /Users/ilyakochik/Developer/refining-company/sql-refining/backend/tests/test_pipeline.py
2025-05-11 15:14:10.143 [info] arg: --rootdir already exists in args, not adding.
2025-05-11 15:14:10.143 [info] Environment variables set for pytest discovery: PYTHONPATH=/Users/ilyakochik/.vscode/extensions/ms-python.python-2025.6.0-darwin-arm64/python_files, TEST_RUN_PIPE=/var/folders/zw/zhs352k55m35_d3twnqwhwdm0000gn/T/python-test-discovery-3d7abe7ac2937b939f47
2025-05-11 15:14:10.144 [info] > ./backend/.venv/bin/python -m pytest -p vscode_pytest --collect-only --quiet --tb=short --rootdir=.
2025-05-11 15:14:10.144 [info] cwd: .
2025-05-11 15:14:10.807 [info] backend/tests/test_pipeline.py::test_pipeline[src.code.ingest_file.0]
backend/tests/test_pipeline.py::test_pipeline[src.sql.parse.2]
backend/tests/test_pipeline.py::test_pipeline[src.code.ingest_file.1]
backend/tests/test_pipeline.py::test_pipeline[src.logic.compare.0]
backend/tests/test_pipeline.py::test_pipeline[src.sql.parse.1]
backend/tests/test_pipeline.py::test_pipeline[src.code.ingest_file.2]
backend/tests/test_pipeline.py::test_pipeline[src.sql.parse.0]
backend/tests/test_pipeline.py::test_pipeline[check_new_or_missing_snapshots]

2025-05-11 15:14:10.808 [info] 
8 tests collected in 0.45s

Python Language Server also doesn't say much

2025-05-11 15:09:38.707 [info] [Info  - 15:09:38] (23960) BG: Indexing(9) started
2025-05-11 15:09:38.708 [info] [Info  - 15:09:38] (23960) Setting environmentName for service "<default>": "3.12.7 (.venv venv)"
2025-05-11 15:09:38.709 [info] [Info  - 15:09:38] (23960) No include entries specified; assuming vscode-chat-code-block://25c8550c-6160-4d48-96d7-9e037d33aca7/
2025-05-11 15:09:38.836 [info] [Info  - 15:09:38] (23960) Assuming Python version 3.9.6.final.0
2025-05-11 15:09:38.914 [info] [Error - 15:09:38] (23960) File or directory "vscode-chat-code-block://25c8550c-6160-4d48-96d7-9e037d33aca7/" does not exist.
2025-05-11 15:09:38.914 [info] [Info  - 15:09:38] (23960) No source files found.
2025-05-11 15:09:38.915 [info] [Info  - 15:09:38] (23960) BG: scanned(9) 29 files over 1 exec env
2025-05-11 15:09:38.979 [info] [Info  - 15:09:38] (23960) Setting environmentName for service "<default>": "3.12.7 (.venv venv)"
2025-05-11 15:09:38.979 [info] [Info  - 15:09:38] (23960) No include entries specified; assuming vscode-chat-code-block://bdab5829-4fcf-4af4-afcb-83941f2aa41e/
2025-05-11 15:09:39.117 [info] [Info  - 15:09:39] (23960) Assuming Python version 3.9.6.final.0
2025-05-11 15:09:39.204 [info] [Error - 15:09:39] (23960) File or directory "vscode-chat-code-block://bdab5829-4fcf-4af4-afcb-83941f2aa41e/" does not exist.
2025-05-11 15:09:39.205 [info] [Info  - 15:09:39] (23960) No source files found.
2025-05-11 15:09:39.212 [info] [Info  - 15:09:39] (23960) BG: indexed(9) 29 files over 1 exec env
2025-05-11 15:09:39.223 [info] [Info  - 15:09:39] (23960) BG: Indexing finished(9).

Extension version: 2025.6.0
VS Code version: Code 1.100.0 (Universal) (19e0f9e681ecb8e5c09d8784acaa601316ca4571, 2025-05-07T12:48:53.763Z)
OS version: Darwin arm64 24.4.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.7
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Installed Extensions
Extension Name Extension Id Version
black-formatter ms- 2025.2.0
copilot Git 1.317.0
copilot-chat Git 0.27.0
copilot-workspace git 0.5.4
debugpy ms- 2025.8.0
esbuild-problem-matchers con 0.0.3
extension-test-runner ms- 0.0.12
js-debug ms- 1.100.0
js-debug-companion ms- 1.1.3
prettier-vscode esb 11.0.0
python ms- 2025.6.0
todo-tree Gru 0.0.226
tsl-problem-matcher amo 0.6.2
vscode-eslint dba 3.0.10
vscode-js-profile-table ms- 1.0.10
vscode-pull-request-github Git 0.110.0
vscode-pylance ms- 2025.4.1
vscode-sqlite ale 0.14.1
System Info
Item Value
CPUs Apple M1 (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 2
Memory (System) 8.00GB (0.09GB free)
Process Argv --crash-reporter-id 2fbdf3e2-1840-4f64-80ad-1c053638da59
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupyter:31046869
pythonrstrctxt:31112756
nativeloc1:31192215
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
e5gg6876:31282496
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
31787653:31262186
3e8i5726:31271747
996jf627:31283433
pythonrdcb7cf:31303019
usemplatestapi:31297334
7bj51361:31289155
747dc170:31275177
g20af354:31278749
pylancecolorcf:31303817
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
gendocf:31295004

Metadata

Metadata

Assignees

Labels

by designrepro workspaceIssue has a retained repro workspaceuser respondedWas "waiting for user response" and they responded

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions