Questions tagged [pyright]

Pyright is a static type checker for Python, developed by Microsoft and implemented in TypeScript. It supports PEP 484, PEP 526, PEP 544 and has smart type inference.

Pyright is a static type checker for Python, developed by Microsoft and implemented in TypeScript. It supports PEP 484, PEP 526, PEP 544 and has smart type inference. It supports the Language Server Protocol and is available in a Visual Studio Code plugin.

154 questions
0
votes
0 answers

"frozen" is not definedPylance (reportUndefinedVariable)

I'm using pylance on VScode for type checking my Python code. It is having trouble with the frozen argument of dataclasses: from dataclasses import dataclass @dataclass(frozen=True) class DataStoreConfig(): store_id: str bucket_name: str …
AHonarmand
  • 530
  • 1
  • 8
  • 16
-1
votes
1 answer

Typing class attributes with default value None - best practices?

I am trying to introduce type hints to legacy Python 2.7 code. Many classes declare class attributes with a default value of None (to avoid mutable defaults) and then assign the value in the constructor, like so: class Myclass(object): _myList =…
FvD
  • 1,286
  • 13
  • 25
-1
votes
1 answer

Why can't you use Dict[str, Any] or Mapping[str, Any] to type **kwargs? How are you supposed to type it?

I am currently trying to learn how to best include types in my Python code, but I'm a little perplexed on how to properly type **kwargs in my function signatures. A minimal example of what I currently have: def foo(name: str, **kwargs: Dict[str,…
ChrissyP
  • 3
  • 2
-1
votes
1 answer

pyright identifies type as Field and not str

pyright (via coc-pyright in vim and pylance in VSCode) identifies the type of an attribute as Field when it is a str. The CreateKeyRingRequest is derived from google's proto.message.Message and, from the documentation, clearly identifies parent as a…
meangrape
  • 317
  • 2
  • 11
1 2 3
10
11