Closed timptner closed 1 month ago
Hey @timptner, do you have any projects you could share that show the issue? I'm not able to reproduce this on my end - here's a project where print is being recognized by pyright:
We've had some issues where restarting Zed, after creating a pyrightconfig.json
file, would correct some weird pyright issues - do your issues still persist after restarting Zed?
Freshly project:
Restartet Zed multiple times in between those 3 options above. Even restarted Zed before creating this project and also tried zed .
while CWD is this project, which some other issue mentioned as solution.
I noticed that each time I restart Zed it always checks for pyright updates and everytime downloads pyright. Don't know if this is expected behaviour.
Just checked with my second workstation (debian) and there I don't get the pyright errors
I've encountered the same problem:
uv init
uv venv
dependencies = ["requests"]
uv pip compile pyproject.toml -o requirements.txt
uv pip sync requirements.txt
import requests
to src/project/__init__.pyThere will be a warning with Pyright: Import "requests" could not be resolved from source
.
As @timptner said, this can be resolved by adding the following to pyproject.toml:
[tool.pyright]
venvPath = "."
venv = ".venv"
However this is a tweak that isn't needed when working in other editors.
@JosephTLyons the same behaviour, venv's libraries pyright recognizing correctly, but pythons builtins not:
Pyright: "str" is not defined (reportUndefinedVariable)
Pyright: "print" is not defined (reportUndefinedVariable)
Pyright: "range" is not defined (reportUndefinedVariable)
Previously it worked fluently, it seems that something became wrong after auto-update
I using the same setting for venv and I tried recreate venv and restart zed. Disable of venv settings also not working.
Just installed pyright
with pip and checked the files.
(.venv) aiven@MacBook-Pro test % pyright --version
pyright 1.1.375
(.venv) aiven@MacBook-Pro test % pyright main.py
0 errors, 0 warnings, 0 informations
Seems like it's a local problem of the pyright version inside Zed.
@timptner for me working this workaround:
rm -rf ~/Library/Application\ Support/Zed/languages/pyright/
After that need to restart Zed and it will automatically download latest pyright version
@timptner for me working this workaround:
rm -rf ~/Library/Application\ Support/Zed/languages/pyright/
After that need to restart Zed and it will automatically download latest pyright version
This has solved it!
This is still a problem on the Linux version of Zed.
After running this command, the newly downloaded pyright has the same issues.
rm -rdf ~/.local/share/zed/languages/pyright/
Check for existing issues
Related issues:
13541 #13206 #12883 #11508 #10587 #7296 #8541 #7646 #5524
Describe the bug / provide steps to reproduce it
Fresh install of Zed and starting a python project with virtualenv pyright highlights all non-standard library imports as unresolvable. This is fine because pyright doesn't know anything about my virtualenv. But it also marks any python standard functions, e. g.
print()
orint()
.(1) Using
./pyproject.toml
it recognizes all custom imports but no longer standard library. Still does not know anything about standard python functions.(2) Using
./pyrightconfig.json
same results as with./pyproject.toml
.(3) Using global
~/.config/zed/settings.json
it does find all third-party libraries installed inside .venv and also finds standard libraries. But it still does not know about standard functions (print, int, dict, sorted, ...).I'm quite sure that some weeks ago I could solve all pyright errors by using
pyproject.toml
orpyrightconfig.json
. But in the meantime nothing seems to work anymore. Using combinations of those 3 options abovepyrightconfig.json
will overwritepyconfig.toml
andsettings.json
in their behaviour.Environment
Zed: v0.146.4 (Zed) OS: macOS 13.6.7 Memory: 8 GiB Architecture: x86_64
Python is installed via brew (python@3.12). PyRight is not installed via brew or as global pip package. (Brew stops one with a warning when trying
python3 -m pip install <package>
outside of an virtualenv.)If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your Zed.log file to this issue.
Zed.log