Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
58 views

I'm using inspect.signature() to get a function signature as a string for generating some documentation by hand, and I'm getting a NameError. I have this minimal Python script to reproduce my problem: ...
7 votes
1 answer
123 views

I'm currently working on a library that uses dataclasses.dataclass classes for data structures. I'm utilizing the metadata argument of the dataclasses.field() method to inject custom library ...
JackTheFoxOtter's user avatar
1 vote
1 answer
118 views

How do the type alias classes (pseudoclasses?) such as typing.Tuple work? They behave like instance objects since their constructors take arguments But they also behave like class objects: they ...
Jason S's user avatar
  • 191k
2 votes
2 answers
70 views

I am working on a Pyomo model with indexed variables, expressions, and constraints, and I am getting some warnings regarding the ComponentData class. The model still runs smoothly, and the results are ...
Schicko's user avatar
  • 51
1 vote
0 answers
92 views

I have a protocol Store (as described here) that looks like: from typing import Protocol, TypeVar, Any type _KeyT[T] = type[T] T = TypeVar('T', bound='SomeClass') class Store(Protocol): def ...
Bobi's user avatar
  • 39
5 votes
0 answers
104 views

Apologies if there is a straightforward answer already that I'm too smooth brained to see. I am working with Python 3.13+ and Mypy 1.19.1. I've read mypy's docs, read several similar questions/answers ...
Knots's user avatar
  • 51
1 vote
3 answers
140 views

Given: from typing import overload, no_type_check from collections.abc import Mapping @overload def f[K, V](arg: Mapping[K, V], /) -> Mapping[K, V]: ... @overload def f[K, V, V2](arg: Mapping[...
yuri kilochek's user avatar
3 votes
2 answers
204 views

I would like to make __slots__-based classes, without having to repeat the attribute names that I've already listed in type annotations. Before Python 3.14, I could do this: class C: foo: int ...
Dan's user avatar
  • 4,582
3 votes
1 answer
151 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
2 votes
1 answer
87 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
109 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
110 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
98 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
2 votes
1 answer
108 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
106 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

15 30 50 per page
1
2 3 4 5
289