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

src seems to be ignored by default #3348

Closed
Tinche opened this issue Sep 16, 2022 · 11 comments
Closed

src seems to be ignored by default #3348

Tinche opened this issue Sep 16, 2022 · 11 comments
Assignees
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@Tinche
Copy link

Tinche commented Sep 16, 2022

Environment data

  • Language Server version: 2022.9.20 (pyright 95c059fa)
  • OS and version: macOS Monterey
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.5

Repro Steps

I've recently noticed VS Code isn't indexing my Python files properly - find usages and workspace symbol search aren't working. My code is inside a src directory.

Looking at the logs, I see:

[Info  - 3:50:40 PM] (7229) Pylance language server 2022.9.20 (pyright 95c059fa) starting
[Info  - 3:50:40 PM] (7229) Server root directory: /Users/tintvrtkovic/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist
[Info  - 3:50:40 PM] (7229) Starting service instance "user-service"
[Info  - 3:50:40 PM] (7229) Notebook support: Legacy
[Info  - 3:50:40 PM] (7229) Interactive window support: Legacy
[Info  - 3:50:40 PM] (7229) No configuration file found.
[Info  - 3:50:40 PM] (7229) pyproject.toml file found at /Users/tintvrtkovic/hr/user-service.
[Info  - 3:50:40 PM] (7229) Setting pythonPath for service "user-service": "/Users/tintvrtkovic/hr/user-service/.venv/bin/python"
[Info  - 3:50:40 PM] (7229) Loading pyproject.toml file at /Users/tintvrtkovic/hr/user-service/pyproject.toml
[Error - 3:50:40 PM] (7229) Pyproject file "/Users/tintvrtkovic/hr/user-service/pyproject.toml" is missing "[tool.pyright]" section.
[Info  - 3:50:40 PM] (7229) Assuming Python version 3.10
[Info  - 3:50:40 PM] (7229) Assuming Python platform Darwin
[Info  - 3:50:40 PM] (7229) Searching for source files
[Info  - 3:50:40 PM] (7229) No source files found.

If I add the directory manually to python.analysis.include, I see:

[Info  - 4:07:30 PM] (7229) Searching for source files
[Info  - 4:07:30 PM] (7229) Found 85 source files

and "Show references" starts working. This used to work before out of the box, so I'm assuming src isn't being scanned by default any more? The docs seem to imply it should be.

@debonte
Copy link
Contributor

debonte commented Sep 16, 2022

@Tinche, any chance you have set:

"python.analysis.diagnosticMode": "workspace",

Wondering if you might be seeing #3343.

@Tinche
Copy link
Author

Tinche commented Sep 16, 2022

Negative, my global and workspace settings do not reference that key :(

@debonte
Copy link
Contributor

debonte commented Sep 16, 2022

Ok, and I'm assuming you don't have python.analysis.autoSearchPaths set to false, since I believe it's the docs for that config setting that you were referring to when you said, "The docs seem to imply it should be."

Is there an __init__.py in your src directory?

If not, could you set "python.analysis.logLevel": "Trace", restart Pylance, and then provide a new "Python Language Server" log?

@Tinche
Copy link
Author

Tinche commented Sep 16, 2022

Oh, interesting, my src does not have an __init__.py. We're using namespace packages since some other code is in the same package, but another directory.

Here's the full log with logLevel: Trace:

[Info  - 10:10:16 PM] (10062) Pylance language server 2022.9.20 (pyright 95c059fa) starting
[Info  - 10:10:16 PM] (10062) Server root directory: /Users/tintvrtkovic/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist
[Info  - 10:10:16 PM] (10062) Starting service instance "user-service"
[Info  - 10:10:16 PM] (10062) Notebook support: Legacy
[Info  - 10:10:16 PM] (10062) Interactive window support: Legacy
[Info  - 10:10:16 PM] (10062) No configuration file found.
[Info  - 10:10:16 PM] (10062) pyproject.toml file found at /Users/tintvrtkovic/hr/user-service.
[Info  - 10:10:16 PM] (10062) Setting pythonPath for service "user-service": "/Users/tintvrtkovic/hr/user-service/.venv/bin/python"
[Info  - 10:10:16 PM] (10062) Loading pyproject.toml file at /Users/tintvrtkovic/hr/user-service/pyproject.toml
[Error - 10:10:16 PM] (10062) Pyproject file "/Users/tintvrtkovic/hr/user-service/pyproject.toml" is missing "[tool.pyright]" section.
[Info  - 10:10:16 PM] (10062) Assuming Python version 3.10
[Info  - 10:10:16 PM] (10062) Assuming Python platform Darwin
[Info  - 10:10:17 PM] (10062) Search paths for /Users/tintvrtkovic/hr/user-service
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/typeshed-fallback/stdlib
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/hr/user-service
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/hr/user-service/src
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/hr/user-service/typings
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/typeshed-fallback/stubs/...
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/.asdf/installs/python/3.10.5/lib/python3.10
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/.asdf/installs/python/3.10.5/lib/python3.10/lib-dynload
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/hr/user-service/.venv/lib/python3.10/site-packages
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/hr/user-service/src
[Info  - 10:10:17 PM] (10062)   /Users/tintvrtkovic/hr/user-service/vendor
[Info  - 10:10:17 PM] (10062) Adding fs watcher for library directories:
 /Users/tintvrtkovic/.asdf/installs/python/3.10.5/lib/python3.10
/Users/tintvrtkovic/.asdf/installs/python/3.10.5/lib/python3.10/lib-dynload
/Users/tintvrtkovic/hr/user-service/.venv/lib/python3.10/site-packages
[Info  - 10:10:17 PM] (10062) Searching for source files
[Info  - 10:10:17 PM] (10062) No source files found.
[Info  - 10:10:17 PM] (10062) Background analysis(1) root directory: /Users/tintvrtkovic/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist
[Info  - 10:10:17 PM] (10062) Background analysis(1) started
(10062) Background analysis message: setConfigOptions
(10062) Background analysis message: setImportResolver
(10062) Background analysis message: ensurePartialStubPackages
(10062) Background analysis message: setTrackedFiles
(10062) Background analysis message: markAllFilesDirty
(10062) Background analysis message: analyze

@debonte
Copy link
Contributor

debonte commented Sep 16, 2022

Apparently, we do not automatically search src if it contains an __init__.py. Anyway, that's why I asked. But you're good there.

Hmmm, the log shows that we are adding src to the search path.

Is this code in a public repo that I can try out on my machine?

@Tinche
Copy link
Author

Tinche commented Sep 16, 2022

No, it's a private repo, but I could try paring it down as much as I can while still reproing and then publishing it somewhere.

@Tinche
Copy link
Author

Tinche commented Sep 16, 2022

I whittled it down to https://github.com/Tinche/vs-code-test.

Still says No source files found. unless I explicitly add src to python.analysis.include, then it says Found 1 source file.

@debonte
Copy link
Contributor

debonte commented Sep 16, 2022

Excellent, thanks! I can repro the issue.

I don't see it in 2022.9.10 (last week's release), so you could work around the issue by switching to that build.

@debonte debonte self-assigned this Sep 16, 2022
@Tinche
Copy link
Author

Tinche commented Sep 16, 2022

Glad I could help and thanks for looking into this ;)

@debonte
Copy link
Contributor

debonte commented Sep 22, 2022

This issue has been fixed in prerelease version 2022.9.31, which we've just released. You can find the changelog here: CHANGELOG.md

@debonte debonte closed this as completed Sep 22, 2022
@Tinche
Copy link
Author

Tinche commented Sep 22, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants