From ecb0610fc6908728f621eaa94d491c338694aa60 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sun, 22 Feb 2026 20:28:19 +0400 Subject: [PATCH 1/3] Add missing __slots__ to third-party packages --- stubs/JACK-Client/jack/__init__.pyi | 2 ++ stubs/WebOb/webob/acceptparse.pyi | 1 + stubs/docutils/docutils/__init__.pyi | 1 + .../google/cloud/ndb/_options.pyi | 15 +++++++++++++++ .../google/cloud/ndb/model.pyi | 1 + .../google/cloud/ndb/query.pyi | 19 +++++++++++++++++++ stubs/icalendar/icalendar/parser.pyi | 1 + stubs/icalendar/icalendar/prop.pyi | 6 ++++++ stubs/pony/pony/orm/dbproviders/postgres.pyi | 3 ++- stubs/psycopg2/psycopg2/_range.pyi | 1 + stubs/psycopg2/psycopg2/extras.pyi | 1 + 11 files changed, 50 insertions(+), 1 deletion(-) diff --git a/stubs/JACK-Client/jack/__init__.pyi b/stubs/JACK-Client/jack/__init__.pyi index 7f5627b79f55..a9aab4df7bde 100644 --- a/stubs/JACK-Client/jack/__init__.pyi +++ b/stubs/JACK-Client/jack/__init__.pyi @@ -271,6 +271,7 @@ class RingBuffer: def size(self) -> int: ... class Status: + __slots__ = "_code" def __init__(self, code: int) -> None: ... @property def failure(self) -> bool: ... @@ -300,6 +301,7 @@ class Status: def client_zombie(self) -> bool: ... class TransportState: + __slots__ = "_code" def __init__(self, code: int) -> None: ... def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... diff --git a/stubs/WebOb/webob/acceptparse.pyi b/stubs/WebOb/webob/acceptparse.pyi index 069564e86749..39030e414d04 100644 --- a/stubs/WebOb/webob/acceptparse.pyi +++ b/stubs/WebOb/webob/acceptparse.pyi @@ -64,6 +64,7 @@ _AcceptLanguageProperty: TypeAlias = AsymmetricPropertyWithDelete[ ] class AcceptOffer(NamedTuple): + __slots__ = () type: str subtype: str params: tuple[tuple[str, str], ...] diff --git a/stubs/docutils/docutils/__init__.pyi b/stubs/docutils/docutils/__init__.pyi index a19ba6ad24e6..6b97f04044aa 100644 --- a/stubs/docutils/docutils/__init__.pyi +++ b/stubs/docutils/docutils/__init__.pyi @@ -15,6 +15,7 @@ class _VersionInfo(NamedTuple): release: bool class VersionInfo(_VersionInfo): + __slots__ = () def __new__( cls, major: int = 0, minor: int = 0, micro: int = 0, releaselevel: str = "final", serial: int = 0, release: bool = True ) -> Self: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/_options.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/_options.pyi index a038bc27cfc8..578a82948c09 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/_options.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/_options.pyi @@ -1,6 +1,20 @@ from _typeshed import Incomplete class Options: + __slots__ = ( + "retries", + "timeout", + "use_cache", + "use_global_cache", + "global_cache_timeout", + "use_datastore", + "force_writes", + "max_memcache_items", + "propagation", + "deadline", + "use_memcache", + "memcache_timeout", + ) @classmethod def options(cls, wrapped, _disambiguate_from_model_properties: bool = ...): ... @classmethod @@ -12,4 +26,5 @@ class Options: def items(self) -> None: ... class ReadOptions(Options): + __slots__ = ("read_consistency", "read_policy", "transaction") def __init__(self, config: Incomplete | None = ..., **kwargs) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi index e13a58438c4f..8a0561f3a625 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -137,6 +137,7 @@ class BlobProperty(Property): def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> bytes | list[bytes] | None: ... class CompressedTextProperty(BlobProperty): + __slots__ = () def __init__(self, *args, **kwargs) -> None: ... class TextProperty(Property): diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/query.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/query.pyi index 939a79444b2c..4f926d6ad8c2 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/query.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/query.pyi @@ -88,6 +88,25 @@ AND = ConjunctionNode OR = DisjunctionNode class QueryOptions(_options.ReadOptions): + __slots__ = ( + "kind", + "ancestor", + "filters", + "order_by", + "orders", + "distinct_on", + "group_by", + "namespace", + "project", + "database", + "keys_only", + "limit", + "offset", + "start_cursor", + "end_cursor", + "projection", + "callback", + ) project: Incomplete namespace: Incomplete database: str | None diff --git a/stubs/icalendar/icalendar/parser.pyi b/stubs/icalendar/icalendar/parser.pyi index c6924bb646b3..1b92de815e51 100644 --- a/stubs/icalendar/icalendar/parser.pyi +++ b/stubs/icalendar/icalendar/parser.pyi @@ -81,6 +81,7 @@ def unescape_list_or_string(val: list[str]) -> list[str]: ... def unescape_list_or_string(val: str) -> str: ... class Contentline(str): + __slots__ = ("strict",) strict: bool def __new__(cls, value: str | bytes, strict: bool = False, encoding: str = "utf-8") -> Self: ... @classmethod diff --git a/stubs/icalendar/icalendar/prop.pyi b/stubs/icalendar/icalendar/prop.pyi index 2675ebe82baf..0528654bfbb0 100644 --- a/stubs/icalendar/icalendar/prop.pyi +++ b/stubs/icalendar/icalendar/prop.pyi @@ -72,6 +72,7 @@ class vBoolean(int): def from_ical(cls, ical: ICAL_TYPE) -> bool: ... class vText(str): + __slots__ = ("encoding", "params") encoding: str params: Parameters def __new__(cls, value: ICAL_TYPE, encoding: str = "utf-8", params: SupportsKeysAndGetItem[str, str] = {}) -> Self: ... @@ -83,6 +84,7 @@ class vText(str): RELTYPE: property class vCalAddress(str): + __slots__ = ("params",) params: Parameters def __new__(cls, value: ICAL_TYPE, encoding: str = "utf-8", params: SupportsKeysAndGetItem[str, str] = {}) -> Self: ... def to_ical(self) -> bytes: ... @@ -213,6 +215,7 @@ class vPeriod(TimeBase): FBTYPE: property class vWeekday(str): + __slots__ = ("params", "relative", "weekday") week_days: Final[CaselessDict[int]] weekday: Literal["SU", "MO", "TU", "WE", "TH", "FR", "SA"] | None relative: int | None @@ -223,6 +226,7 @@ class vWeekday(str): def from_ical(cls, ical: ICAL_TYPE) -> Self: ... class vFrequency(str): + __slots__ = ("params",) frequencies: Final[CaselessDict[str]] params: Parameters def __new__(cls, value: ICAL_TYPE, encoding: str = "utf-8", params: SupportsKeysAndGetItem[str, str] = {}) -> Self: ... @@ -285,6 +289,7 @@ class vTime(TimeBase): def from_ical(ical: ICAL_TYPE) -> datetime.time: ... class vUri(str): + __slots__ = ("params",) params: Parameters def __new__(cls, value: ICAL_TYPE, encoding: str = "utf-8", params: SupportsKeysAndGetItem[str, str] = {}) -> Self: ... def to_ical(self) -> bytes: ... @@ -313,6 +318,7 @@ class vUTCOffset: def __hash__(self) -> int: ... class vInline(str): + __slots__ = ("params",) params: Parameters def __new__(cls, value: ICAL_TYPE, encoding: str = "utf-8", params: SupportsKeysAndGetItem[str, str] = {}) -> Self: ... def to_ical(self) -> bytes: ... diff --git a/stubs/pony/pony/orm/dbproviders/postgres.pyi b/stubs/pony/pony/orm/dbproviders/postgres.pyi index f3aef861eebe..a2f472c3890d 100644 --- a/stubs/pony/pony/orm/dbproviders/postgres.pyi +++ b/stubs/pony/pony/orm/dbproviders/postgres.pyi @@ -21,7 +21,8 @@ class PGSchema(dbschema.DBSchema): class PGTranslator(SQLTranslator): dialect: ClassVar[str] -class PGValue(Value): ... +class PGValue(Value): + __slots__: list[str] = [] class PGSQLBuilder(SQLBuilder): dialect: ClassVar[str] diff --git a/stubs/psycopg2/psycopg2/_range.pyi b/stubs/psycopg2/psycopg2/_range.pyi index eec56727e740..cc777c4774b9 100644 --- a/stubs/psycopg2/psycopg2/_range.pyi +++ b/stubs/psycopg2/psycopg2/_range.pyi @@ -8,6 +8,7 @@ from psycopg2._psycopg import _type, connection, cursor _T_co = TypeVar("_T_co", covariant=True) class Range(Generic[_T_co]): + __slots__ = ("_lower", "_upper", "_bounds") def __init__( self, lower: _T_co | None = None, upper: _T_co | None = None, bounds: str = "[)", empty: bool = False ) -> None: ... diff --git a/stubs/psycopg2/psycopg2/extras.pyi b/stubs/psycopg2/psycopg2/extras.pyi index 97c67b40863a..1820c9c0f055 100644 --- a/stubs/psycopg2/psycopg2/extras.pyi +++ b/stubs/psycopg2/psycopg2/extras.pyi @@ -71,6 +71,7 @@ class DictCursor(DictCursorBase): def __next__(self) -> DictRow: ... # type: ignore[override] class DictRow(list[Any]): + __slots__ = ("_index",) def __init__(self, cursor) -> None: ... def __getitem__(self, x): ... def __setitem__(self, x, v) -> None: ... From 5924ae6ac3e42425a3d05e354f2a4b009d8656a9 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sun, 22 Feb 2026 21:44:46 +0400 Subject: [PATCH 2/3] [webob] remove slots for namedtuple --- stubs/WebOb/webob/acceptparse.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/WebOb/webob/acceptparse.pyi b/stubs/WebOb/webob/acceptparse.pyi index 39030e414d04..069564e86749 100644 --- a/stubs/WebOb/webob/acceptparse.pyi +++ b/stubs/WebOb/webob/acceptparse.pyi @@ -64,7 +64,6 @@ _AcceptLanguageProperty: TypeAlias = AsymmetricPropertyWithDelete[ ] class AcceptOffer(NamedTuple): - __slots__ = () type: str subtype: str params: tuple[tuple[str, str], ...] From fb92ef7b3b2dd4c6f1420057a4a80612f32fdb3a Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sun, 22 Feb 2026 22:00:30 +0400 Subject: [PATCH 3/3] [webob] Create _AcceptOffer namedtuple --- stubs/WebOb/webob/acceptparse.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stubs/WebOb/webob/acceptparse.pyi b/stubs/WebOb/webob/acceptparse.pyi index 069564e86749..2456fd19ff33 100644 --- a/stubs/WebOb/webob/acceptparse.pyi +++ b/stubs/WebOb/webob/acceptparse.pyi @@ -63,11 +63,15 @@ _AcceptLanguageProperty: TypeAlias = AsymmetricPropertyWithDelete[ ), ] -class AcceptOffer(NamedTuple): +@type_check_only +class _AcceptOffer(NamedTuple): type: str subtype: str params: tuple[tuple[str, str], ...] +class AcceptOffer(_AcceptOffer): + __slots__ = () + class Accept: @classmethod def parse(cls, value: str) -> Iterator[_ParsedAccept]: ...