Comments (3)
Ah, it looks like you've installed two python environments (3.6 and 3.7) into the same virtual environment. Pyright found "python3.6" because that's the first that was returned by the file system. The whole purpose of virtual environments is to isolate different python installations, so I think it's considered an error to install two python environments in the same venv. If you really need two versions, you should create two parallel venvs (e.g. "dev36" and "dev37").
from pyright.
It looks like the current code in Pyright might fail under Windows, but that doesn't explain the problem you're seeing since you're on MacOS. I think it's a configuration issue in your case. You need to tell Pyright two pieces of information:
venvPath
: The directory that contains your virtual environments (in your case, ~/.venv
)
venv
: The virtual environment you want to use (in your case, "dev")
You can specify both of these in the pyrightconfig.json file, but you can't use shell notation ~
, so you'd need to expand the venvPath manually (e.g. "/Users/rrelict/.venv"). You can also specify the venvPath in your VS Code settings, and Pyright will pick it up from there.
from pyright.
Eric, thanks for the datails.
My pyrightconfig.json
seems correct:
{
"venvPath": "/Users/rrelict/.venv",
"venv": "dev"
}
venv dir structure is:
~/.venv> ls dev/lib/*/
dev/lib/python3.6/:
site-packages
dev/lib/python3.7/:
site-packages
VSCode shows a problems output:
Import 'sqlitedict' could not be resolved
't' is not bound
Import 'telegram.ext' could not be resolved
There are not resolved imports.
To fix it I did a symlink:
~/.venv> cd dev/lib/
~/.v/d/lib> ln -s python3.7/site-packages/ ./site-packages
After restarting of VSCode the problems output is:
't' is not bound
It solved my issue with not resolved imports.
As referenced above the problem may be in the pyright
code:
https://github.com/Microsoft/pyright/blob/5cde770e9ddb4de12f2b8f675db7aa124fe378c3/server/src/analyzer/pythonPathUtils.ts#L52-L53
from pyright.
Related Issues (20)
- Pyright unable to infer the type of Generic classmethod HOT 1
- Regression: Generic decorator breaks the inference of complex types with unions
- Guarding an optional type of an attribute doesn't help to match a protocol HOT 3
- Regression: ParamSpec type narrowing HOT 1
- 3.13 Deprecated decorator has issues with decorator stacking HOT 10
- Incorrect `reportOperatorIssue` error when comparing tuples HOT 5
- useLibraryCodeForTypes has been specified in both the config file and the client settings—in LSP HOT 2
- Bug when using protocols with callable fields HOT 3
- String-form generic parameter in base class list not recognized with PEP 695 syntax HOT 1
- Constant redefinition detected in mutually exclusive blocks HOT 3
- Regression: property of complex decorator fails. HOT 1
- Incorrect type inference in dict comprehension with union return value HOT 1
- Operator issue with sqlalchemy.func HOT 6
- Pyright out of memory w/Neovim HOT 2
- None check be invalidity within the def or lambda within the for loop HOT 1
- Tagged union boolean discriminant HOT 1
- Django TextChoices causes a false-positive reportCallIssue error HOT 1
- NoReturn return type from __init__ ignored HOT 1
- `TypeIs` narrows constrained type variable to `Never` HOT 2
- Prebuilt node install fails - v22.0.0 not found HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyright.