Skip to main content
3 votes
1 answer
104 views

Implementing a virtual file system I encounter a circular import problem. common.py: from typing import TYPE_CHECKING if TYPE_CHECKING: from .directory import Directory from .archive import ...
big_cat's user avatar
  • 67
1 vote
1 answer
71 views

I am trying to use variadic generics to express the following pattern: given a variadic list of classes, return a tuple of instances whose types correspond positionally to the input classes. ...
Tymon Marek's user avatar
1 vote
0 answers
61 views

When I use a signal's connect method, basedpyright gives a warning. I use the signal as is in the documentation: some_object.someSignal.connect(some_callable). It works, the only problem is the ...
petersohn's user avatar
  • 11.9k
4 votes
1 answer
99 views

I'm trying to hint that a Pydantic BaseModel field needs to be the class tuple or one of its subclasses, so I've typed the field as type[tuple]: from pydantic import BaseModel class Task1(BaseModel): ...
bin9980's user avatar
  • 71
3 votes
1 answer
87 views

In order to narrow type into literal types, I usually do the following: from typing import Literal, TypeIs, get_args, reveal_type type OneTwoThree = Literal[1, 2, 3] type FourFiveSix = Literal[4, 5, ...
Leonardus Chen's user avatar
3 votes
1 answer
80 views

I struggle with typechecks using matplotlib.pyplot.subplot_mosaic. I have create the following fuction, which generates the mosaic pattern and the per_subplot_kw: def create_mosaic(num_rows): def ...
MaKaNu's user avatar
  • 1,108
0 votes
1 answer
98 views

How to type libraries using ahk? I thought about doing it like this: class AHKMouseController: def __init__( self, ahk: AHK ): self._ahk = ahk But mypy complains: ...
AsfhtgkDavid's user avatar
Best practices
2 votes
2 replies
126 views

I am working with an application that uses Pydantic models extensively. Many attributes on these models are set to Optional but with a default value to ensure that they are not None. The intent is ...
Tim Pierce's user avatar
  • 5,704
1 vote
1 answer
89 views

I'm using basedpyright for static type checking, and it fails to resolve imports from a test utility module located under the tests directory. However, unittest executes the tests without any issues. ...
usan's user avatar
  • 179
3 votes
2 answers
122 views

I'm overloading a method so the return type differs depending on the value of a given bool parameter. That same parameter has a default value (False in my case). Here's a simplistic example function ...
chrsmrrtt's user avatar
  • 329
Best practices
0 votes
1 replies
41 views

I'm building a simulation engine in Python and want to use generics so that events are strongly typed to a simulation state. I have something like this: from __future__ import annotations from abc ...
Davis Cotton's user avatar
3 votes
1 answer
94 views

Pyright type inference seems unable to convert unions of homogeneous sequences, e.g. from Union[tuple[A, ...], tuple[B, ...]] to Union[list[A], list[B]]. Suppose a function which takes as input an ...
Vexx23's user avatar
  • 203
0 votes
1 answer
97 views

I have a setup like the following from typing import Generic, TypeVar T = TypeVar("T") class ThirdParty: def __init_subclass__(cls): ... # does not call super() class Mine(...
Daraan's user avatar
  • 5,187
3 votes
1 answer
135 views

I recently upgraded mypy from 1.17.0 to 1.18.2 The following code was successfully validated in the old mypy version (1.17.0), but fails in the new one (1.18.2): _T = TypeVar('_T') class Foo(Generic[...
Georg Plaz's user avatar
  • 6,126
2 votes
2 answers
142 views

We use pyre for linting and have been updating some old polymorphic code to be typed. The __init__ method has quite a few arguments and was using **kwargs to pass them through the various layers with ...
tsuckow's user avatar
  • 21

15 30 50 per page
1
2 3 4 5
288