536 questions
1
vote
1
answer
938
views
How to resolve pylance "Series[Unknown]" error for dataframe using applymap
I've been running into the following pylance error.
Object of type "Series[Unknown]" is not callable
Sample code to recreate error:
import pandas as pd
df = pd.DataFrame({'col1': ['a', 'b', ...
2
votes
1
answer
376
views
Replicate Pylance analysis in Pyright
I've configured my VS Code project to use the Pylance extension. I know that Pylance is using Pyright internally.
We have a "no-warning" policy. I want to enforce this by running Pyright (in ...
1
vote
0
answers
3k
views
Pylance: use Mypy for autocomplete
I have python code that uses __getattr__ to relay non existing member accesses to another object.
I have written a Mypy plugin which makes the type hints work.
class StrProxy(Proxy[str])
s: str
...
0
votes
1
answer
639
views
Why doesn't VS Code's Pylance show function descriptions for OpenCV?
I just installed MS VS Code and all of the recommended extensions for Python, including Pylance. In every tutorial for OpenCV I see, there are descriptions shown for every single function when I type ...
1
vote
1
answer
178
views
Pylance doesn't recognize attrs.field with converters
Pylance seems to recognize an attrs field as a function (rather than a variable) when the paramter converter= is specified. How to correct it? (Python v3.8.13, Pylance
v2023.12.100)
from typing import ...
1
vote
1
answer
524
views
Python language server fails to start in VSCode 1.84.0
With the latest official Python extension, Pylance fails to index python files:
enter image description here
The output of the Python language server output tab is:
2023-12-13 15:30:15.510 [info] [...
0
votes
1
answer
141
views
Import "___" could not be resolved PylancereportMissingImports
Whenever I install a new library, I get this error from VScode. I searched up how to fix it and got confused.
One solution told me to Ctrl+Shift+P, select the python interpreter. on my computer, and ...
0
votes
1
answer
1k
views
Pylance don't work in my root folder, but work in other folder. Why did this happen?
I use VSCode write my code in remote Linux Server with Python and Pylance extensions. but the Pylance don't work in my root folder, like this:
Pylance don't work, the color of import module don't ...
0
votes
1
answer
517
views
VSCode Pylance shows [reportMissingImports] while importing some of tensorflow submodules
I'm using conda environment in vscode. TensorFlow is installed and can be used properly. But Pylance show [reportMissingImports] in some of imported submodules or classes, etc. For example, refer to ...
2
votes
1
answer
2k
views
Pylint extension disables Pylance extension in VS Code
I have been using Pylance for auto suggestions and completions.
Recently i added Pylint to help me lint my code but the moment i installed Pylint my Pylance stopped working (its not giving any auto ...
3
votes
3
answers
682
views
Pylance not working autocomplete for dynamically instantiated classes
from typing import Literal, overload, TypeVar, Generic, Type
import enum
import abc
import typing
class Version(enum.Enum):
Version1 = 1
Version2 = 2
Version3 = 3
import abc
from typing ...
0
votes
1
answer
341
views
Methods and attributes do not show when dot is pressed (intellisense)
Yesterday I upgraded from 3.11 to python 3.12.
The editor that i use is VScode.
When i use standard patterns with matplotlib (from the official docs), the intellisense does not recognise the types and ...
2
votes
0
answers
956
views
Pylance does not see stub files
I have the following structure:
mypackage/
├─ subpackage/
│ ├─ __init__.py
│ ├─ module.py
│ ├─ module.pyi
├─ __init__.py
File mudule.pyi contains:
class Apple:
tree: Tree
class Tree:
...
-1
votes
1
answer
66
views
Pylance getting "Expect expression" and "Zero-length tuple is not allowed in this context" for dict indexing
I am attempting to get a value from a h5 dataset using h5py with the dict-like indexing. I tested the code and it works, but pylance shows me this error in vscode.
The error "Expect expression&...
0
votes
1
answer
585
views
"reportMissingImports" error even though code and import works fine in VSCode
Small question but annoying. In VSCode, it is reporting a "reportMissingImports" error even though the import and the code is working fine. Here is the relevant portion.
import requests
from ...
2
votes
1
answer
416
views
Pylance - Unresolved import warnings
I'm using VSCode. Although my code runs as expected, I'm getting linting errors.
The code:
import tensorflow.keras as keras
The error: Import "tensorflow.keras" could not be resolved.
I've ...
1
vote
0
answers
143
views
QuickFix and automatic import suggestions not working with package published with Poetry
When I install a Pypi package which I published via Poetry, I am not able to get import suggestions by VsCode. With Pycharm that works fine.
I expect it to show up here:
Missing import suggestion
This ...
1
vote
0
answers
164
views
Python Linter or intellisense or pylance in VSCode not working in server path
in the last week, I had a problem with my VsCode, I'm developing Python RPA and the lint (pylance) didn't work in the local server path, does not identify the function, and the possible errors
Program ...
1
vote
1
answer
282
views
Pylance and Sympy Object
I am working with SymPy package (https://www.sympy.org/en/index.html).
The code runs fine, for example, this small portion of code:
from sympy import Symbol, exp, integrate
x = Symbol('x')
f = 2.5*exp(...
0
votes
0
answers
159
views
VSCode doesn't show docstring for pandas module and some functions like read_csv
VSCode doesn't show the docstring for the import pandas. This is show for other libraries like Numpy and Scipy. Also is doesn't show the docstring for read_csv, but for read_excel is show. The ...
0
votes
1
answer
933
views
Import Error in Visual Studio Code Despite Extensive Troubleshooting(Python)
Edit: Solved, I had to create a virtual environment apparently. After I created one and started working from there, importing worked fine.
I've encountered a persistent issue in Visual Studio Code (...
1
vote
0
answers
106
views
Type Validation Based on the Contents of a JSON file
This is similar to this question, except here the valid arguments are contained in a json file.
In Python using VSCode, I'd like to define a type which is based on the contents of a JSON file. Is such ...
3
votes
3
answers
8k
views
Why Python imports cannot be resolved by Pylance in VS Code, if the package is located in a shared folder?
I am using Pylance extension in VS Code. Some packages import cannot be resolved by Pylance. I found out that these packages are located in a shared folder and the UNC Path of this folder is in the ...
1
vote
1
answer
2k
views
Argument of type "SupportsRichComparison" cannot be assigned to parameter "__x" of type "str | ReadableBuffer | SupportsInt | SupportsIndex
I have a list of numbers with some elements being characters instead.
I make a function so that it filter out any character, it works but if I use the
max() function on the list and assign it to a ...
0
votes
0
answers
429
views
How can I programmatically extract type information from a Python project using Pylance?
I'm working on a project where I need to analyze a Python codebase and extract type information for specific variables programatically. I'm interested in using Pylance (or the underlying Pyright) ...