pyright Questions

1

Solved

Fresh installed neovim on a new LinuxMint machine with lsp-config, mason plugins and pyright LSP Server (through Mason) and found out that it was not working with lsp.log registering this !!! .../...
Caudad asked 3/3 at 5:25

3

Solved

Some of the packages I use don't type hint their code, so when I use them, Pylance keeps telling me that the functions I use have partially unknown types, which is a problem I can't fix. Is there a...
Disclimax asked 25/8, 2021 at 3:30

4

I am using the pyright LSP in neovim (0.5). It works, but seems to only pick up on packages available in the standard python installation. It does not autocomplete for packages not in the base pyth...
Henceforward asked 22/1, 2021 at 14:35

2

Solved

I cannot quite find clear documentation on how to ignore one or more specific Pyright checks: Using a config file at the root of your project. At the top of a file, function, or method. Each ligne...
Necessarily asked 17/8, 2021 at 18:53

2

Consider the following snippet: from typing import TypeVar import numpy as np T = TypeVar("T", float, np.ndarray) def f(x: T) -> T: """ expects a float or an array...
Gman asked 6/12, 2023 at 14:46

1

pyright reports both missing imports (could not be resolved) and general type errors (unknown import symbol). These libraries all exist -- I can run the code in ipython without errors. I'm using po...
Vandiver asked 24/6, 2022 at 18:18

2

Solved

(Related, but not duplicated: How to annotate attribute that can be implemented as property?) I want to create a Protocol, in which a field can be implemented by both a simple type and property. Fo...
Teller asked 10/7, 2021 at 6:15

0

I would like pyright installed by Mason to use the current conds environment, that is the one used when opening neovim. If I put a pyrightconfig.json shown below in root dir of my project, this wil...
Minx asked 8/3, 2023 at 7:28

3

Solved

I love Pylance type checking. However, If I have a variable var: Union[None, T], where T implements foo, pylance will throw an error at: var.foo() since type None doesn't implement foo. Is there an...
Laissezfaire asked 19/7, 2021 at 20:27

7

Solved

I've just started using Pyright. Running it on files that run perfectly well I get plenty of errors. This question is similar, but refers to one's own modules. For example Import "numpy" could ...
Khiva asked 6/4, 2020 at 4:18

1

Solved

Consider a Python protocol attribute which is also annotated with a protocol. I found in that case, both mypy and Pyright report an error even when my custom datatype follows the nested protocol. F...
Prefigure asked 22/1, 2023 at 7:51

2

Solved

Lately I was doing some ML stuff with Python using scikit-learn package. I wanted to use make_blobs() function so I began writing code for example: X, y = make_blobs(n_samples=m, centers=2, n_featu...

3

I'm using pyright for type checking and I'm also using pytest for testing inside Visual Studio Code. The folder structure for my tests is to have a 'test' subfolder in the package root . For exampl...
Selig asked 29/11, 2019 at 17:9

1

Solved

The July 2022 release of the Python extension for Visual Studio Code introduced "Inlay Type Hints", which automatically suggests return types of functions that don't have an explicit anno...
Albeit asked 18/10, 2022 at 12:33

1

I setup Neovim LSP using the nvim-lspconfig and the lsp-installer where I also installed the pyright server. Without any further configuration it worked out of the box. However when I have a class ...
Quinquefid asked 15/7, 2022 at 10:9

1

I'm splitting my code into multiple packages, which are installable via PyPI. Then these packages are used in a child package, where I want type information from "library" packages to be ...
Danley asked 15/12, 2021 at 13:28

1

I am using pyright type checker and need to suppress warnings where e.g. numpy type stubs are insufficient to infer correct types. This can be accomplished with #type: ignore comment. However, I'd ...
Walston asked 24/12, 2021 at 11:36

1

I'm wondering what's the best approach to deal with unknown types of functions/methods associated with other modules. Note that I'm using strict mode For example, I have the following: rooms: List[...
Shannan asked 27/4, 2021 at 13:34

1

Solved

I'm used to typescript, in which one can use a ! to tell the type-checker to assume a value won't be null. Is there something analogous when using type annotations in python? A (contrived) example:...
Allpowerful asked 9/4, 2022 at 5:12

2

Solved

def func(df_a: pd.DataFrame, df_b: pd.DataFrame) -> (pd.DataFrame, pd.DataFrame): Pylance is advising to modify this line with two solution proposed. What would be the pros and cons of each one...
Arly asked 31/1, 2022 at 16:54

2

Solved

I need to ignore pyright checking for one line. Is there any special comment for it? def create_slog(group: SLogGroup, data: Optional[dict] = None): SLog.insert_one(SLog(group=group, data=data)) ...
Flood asked 3/8, 2019 at 5:12

1

Solved

I have the following (typed) Python function: from typing import overload, Literal, NoReturn @overload def check(condition: Literal[False], msg: str) -> NoReturn: pass @overload def check(con...
Prickett asked 12/12, 2021 at 20:38

2

I wish to perform static type checking (pylance in vscode) on some dictionaries. The "tricky" part is the I want some of the parameters to be optional and not show up at all in the dictio...
Mitman asked 9/7, 2020 at 21:29

1

update 2024: sqlalchemy 2.0 has much better typing support I'm using Pylance (with type hints powered by PyRight) in VSCode, and have the following function: def sample(session: sqlalchemy.orm.Sess...
Flaw asked 8/12, 2021 at 5:17

1

When I open a python file, diagnostics seem to be working fine. Then I navigate to a line with a diagnostic error, press the shortcut to invoke code actions ('<space>ca' in my case) and I get...

© 2022 - 2024 — McMap. All rights reserved.