8000 Third-party stubs: enforce CamelCase for type alias names (#8256) · python/typeshed@e3d4bdc · GitHub
[go: up one dir, main page]

Skip to content

Commit e3d4bdc

Browse files
Third-party stubs: enforce CamelCase for type alias names (#8256)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 4b34b34 commit e3d4bdc

File tree

13 files changed

+69
-68
lines changed

13 files changed

+69
-68
lines changed

stubs/SQLAlchemy/sqlalchemy/sql/base.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from typing import Any, ClassVar
55
from .. import util
66
from ..util import HasMemoized, hybridmethod, memoized_property
77
from . import roles
8+
from .elements import ColumnElement
89
from .traversals import (
910
HasCacheKey as HasCacheKey,
1011
HasCopyInternals as HasCopyInternals,
@@ -151,7 +152,7 @@ class ImmutableColumnCollection(util.ImmutableContainer, ColumnCollection):
151152
extend: Any
152153
remove: Any
153154

154-
class ColumnSet(util.ordered_column_set):
155+
class ColumnSet(util.ordered_column_set[ColumnElement[Any]]):
155156
def contains_column(self, col): ...
156157
def extend(self, cols) -> None: ...
157158
def __add__(self, other): ...

stubs/SQLAlchemy/sqlalchemy/util/_collections.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import collections.abc
22
from _typeshed import Self, SupportsKeysAndGetItem
33
from collections.abc import Callable, Iterable, Iterator, Mapping
44
from typing import Any, Generic, NoReturn, TypeVar, overload
5-
from typing_extensions import TypeAlias
65

76
from ..cimmutabledict import immutabledict as immutabledict
8-
from ..sql.elements import ColumnElement
97

108
_KT = TypeVar("_KT")
119
_VT = TypeVar("_VT")
@@ -163,7 +161,11 @@ class WeakPopulateDict(dict[Any, Any]):
163161

164162
column_set = set
165163
column_dict = dict
166-
ordered_column_set: TypeAlias = OrderedSet[ColumnElement[Any]]
164+
# Ignore Y026, this isn't a type alias.
165+
# We have to do `ordered_column_set = OrderedSet[_T]
166+
# instead of `ordered_column_set = OrderedSet`,
167+
# or pyright complains
168+
ordered_column_set = OrderedSet[_T] # noqa: Y026
167169

168170
def unique_list(seq: Iterable[_T], hashfunc: Callable[[_T], Any] | None = ...) -> list[_T]: ...
169171

stubs/SQLAlchemy/sqlalchemy/util/_concurrency_py3k.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ from typing_extensions import TypeAlias
55

66
from .langhelpers import memoized_property
77

8-
_greenlet: TypeAlias = Any # actually greenlet.greenlet
8+
_Greenlet: TypeAlias = Any # actually greenlet.greenlet
99

1010
def is_exit_exception(e): ...
1111

12-
class _AsyncIoGreenlet(_greenlet):
12+
class _AsyncIoGreenlet(_Greenlet):
1313
driver: Any
1414
gr_context: Any
1515
def __init__(self, fn, driver) -> None: ...

stubs/boto/boto/utils.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ class LRUCache(dict[_KT, _VT]):
9696
def __init__(self, capacity: int) -> None: ...
9797

9898
# This exists to work around Password.str's name shadowing the str type
99-
_str: TypeAlias = str
99+
_Str: TypeAlias = str
100100

101101
class Password:
102102
hashfunc: Callable[[bytes], _Hash]
103-
str: _str | None
104-
def __init__(self, str: _str | None = ..., hashfunc: Callable[[bytes], _Hash] | None = ...) -> None: ...
105-
def set(self, value: bytes | _str) -> None: ...
106-
def __eq__(self, other: _str | bytes | None) -> bool: ... # type: ignore[override]
103+
str: _Str | None
104+
def __init__(self, str: _Str | None = ..., hashfunc: Callable[[bytes], _Hash] | None = ...) -> None: ...
105+
def set(self, value: bytes | _Str) -> None: ...
106+
def __eq__(self, other: _Str | bytes | None) -> bool: ... # type: ignore[override]
107107
def __len__(self) -> int: ...
108108

109109
def notify(

stubs/caldav/caldav/objects.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ from .lib.url import URL
1313

1414
_CC = TypeVar("_CC", bound=CalendarObjectResource)
1515

16-
_vCalAddress: TypeAlias = Any # actually icalendar.vCalAddress
16+
_VCalAddress: TypeAlias = Any # actually icalendar.vCalAddress
1717

1818
class DAVObject:
1919
id: str | None
@@ -58,7 +58,7 @@ class Principal(DAVObject):
5858
self, name: str | None = ..., cal_id: str | None = ..., supported_calendar_component_set: Any | None = ...
5959
) -> Calendar: ...
6060
def calendar(self, name: str | None = ..., cal_id: str | None = ...) -> Calendar: ...
61-
def get_vcal_address(self) -> _vCalAddress: ...
61+
def get_vcal_address(self) -> _VCalAddress: ...
6262
calendar_home_set: CalendarSet # can also be set to anything URL.objectify() accepts
6363
def freebusy_request(self, dtstart, dtend, attendees): ...
6464
def calendar_user_address_set(self) -> list[str]: ...

stubs/html5lib/html5lib/_tokenizer.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from typing import Any
2-
from typing_extensions import TypeAlias
32

43
entitiesTrie: Any
5-
attributeMap: TypeAlias = dict[Any, Any]
4+
attributeMap = dict
65

76
class HTMLTokenizer:
87
stream: Any

stubs/psutil/psutil/__init__.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from _typeshed import Self
33
from collections.abc import Callable, Iterable, Iterator
44
from contextlib import AbstractContextManager
55
from typing import Any
6-
from typing_extensions import TypeAlias
76

87
from ._common import (
98
AIX as AIX,
@@ -109,8 +108,8 @@ elif sys.platform == "darwin":
109108
elif sys.platform == "win32":
110109
from ._pswindows import pfullmem, pmem
111110
else:
112-
pmem: TypeAlias = Any
113-
pfullmem: TypeAlias = Any
111+
class pmem(Any): ...
112+
class pfullmem(Any): ...
114113

115114
if sys.platform == "linux":
116115
PROCFS_PATH: str

stubs/psycopg2/psycopg2/_psycopg.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class cursor:
112112
def __iter__(self: Self) -> Self: ...
113113
def __next__(self) -> tuple[Any, ...]: ...
114114

115-
_cursor: TypeAlias = cursor
115+
_Cursor: TypeAlias = cursor
116116

117117
class AsIs:
118118
adapted: Any
@@ -246,7 +246,7 @@ class Diagnostics:
246246
def __init__(self, __err: Error) -> None: ...
247247

248248
class Error(Exception):
249-
cursor: _cursor | None
249+
cursor: _Cursor | None
250250
diag: Diagnostics
251251
pgcode: str | None
252252
pgerror: str | None
@@ -357,7 +357,7 @@ class Xid:
357357
def __getitem__(self, __index): ...
358358
def __len__(self): ...
359359

360-
_T_cur = TypeVar("_T_cur", bound=_cursor)
360+
_T_cur = TypeVar("_T_cur", bound=cursor)
361361

362362
class connection:
363363
DataError: Any
@@ -377,7 +377,7 @@ class connection:
377377
def binary_types(self) -> Any: ...
378378
@property
379379
def closed(self) -> int: ...
380-
cursor_factory: Callable[..., _cursor]
380+
cursor_factory: Callable[..., _Cursor]
381381
@property
382382
def dsn(self) -> str: ...
383383
@property
@@ -415,7 +415,7 @@ class connection:
415415
def close(self) -> None: ...
416416
def commit(self) -> None: ...
417417
@overload
418-
def cursor(self, name: str | bytes | None = ..., *, withhold: bool = ..., scrollable: bool | None = ...) -> _cursor: ...
418+
def cursor(self, name: str | bytes | None = ..., *, withhold: bool = ..., scrollable: bool | None = ...) -> _Cursor: ...
419419
@overload
420420
def cursor(
421421
self,

stubs/python-dateutil/dateutil/relativedelta.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from ._common import weekday
99
_SelfT = TypeVar("_SelfT", bound=relativedelta)
1010
_DateT = TypeVar("_DateT", date, datetime)
1111
# Work around attribute and type having the same name.
12-
_weekday: TypeAlias = weekday
12+
_Weekday: TypeAlias = weekday
1313

1414
MO: weekday
1515
TU: weekday
@@ -30,7 +30,7 @@ class relativedelta:
3030
microseconds: int
3131
year: int | None
3232
month: int | None
33-
weekday: _weekday | None
33+
weekday: _Weekday | None
3434
day: int | None
3535
hour: int | None
3636
minute: int | None
@@ -52,7 +52,7 @@ class relativedelta:
5252
year: int | None = ...,
5353
month: int | None = ...,
5454
day: int | None = ...,
55-
weekday: int | _weekday | None = ...,
55+
weekday: int | _Weekday | None = ...,
5656
yearday: int | None = ...,
5757
nlyearday: int | None = ...,
5858
hour: int | None = ...,

stubs/python-dateutil/dateutil/rrule.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class _iterinfo:
8484
def mtimeset(self, hour, minute, second): ...
8585
def stimeset(self, hour, minute, second): ...
8686

87-
_rrule: TypeAlias = rrule
87+
_RRule: TypeAlias = rrule
8888

8989
class rruleset(rrulebase):
9090
class _genitem:
@@ -100,7 +100,7 @@ class rruleset(rrulebase):
100100
def __ne__(self, other): ...
101101

102102
def __init__(self, cache: bool = ...) -> None: ...
103-
def rrule(self, rrule: _rrule): ...
103+
def rrule(self, rrule: _RRule): ...
104104
def rdate(self, rdate): ...
105105
def exrule(self, exrule): ...
106106
def exdate(self, exdate): ...

stubs/typed-ast/typed_ast/ast27.pyi

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PyCF_ONLY_AST: int
2424

2525
# ast classes
2626

27-
_identifier: TypeAlias = str
27+
_Identifier: TypeAlias = str
2828

2929
class AST:
3030
_attributes: tuple[str, ...]
@@ -55,14 +55,14 @@ class stmt(AST):
5555
col_offset: int
5656

5757
class FunctionDef(stmt):
58-
name: _identifier
58+
name: _Identifier
5959
args: arguments
6060
body: list[stmt]
6161
decorator_list: list[expr]
6262
type_comment: str | None
6363

6464
class ClassDef(stmt):
65-
name: _identifier
65+
name: _Identifier
6666
bases: list[expr]
6767
body: list[stmt]
6868
decorator_list: list[expr]
@@ -133,7 +133,7 @@ class Import(stmt):
133133
names: list[alias]
134134

135135
class ImportFrom(stmt):
136-
module: _identifier | None
136+
module: _Identifier | None
137137
names: list[alias]
138138
level: int | None
139139

@@ -143,7 +143,7 @@ class Exec(stmt):
143143
locals: expr | None
144144

145145
class Global(stmt):
146-
names: list[_identifier]
146+
names: list[_Identifier]
147147

148148
class Expr(stmt):
149149
value: expr
@@ -153,7 +153,7 @@ class Break(stmt): ...
153153
class Continue(stmt): ...
154154
class slice(AST): ...
155155

156-
_slice: TypeAlias = slice # this lets us type the variable named 'slice' below
156+
_Slice: TypeAlias = slice # this lets us type the variable named 'slice' below
157157

158158
class Slice(slice):
159159
lower: expr | None
@@ -245,16 +245,16 @@ class Str(expr):
245245

246246
class Attribute(expr):
247247
value: expr
248-
attr: _identifier
248+
attr: _Identifier
249249
ctx: expr_context
250250

251251
class Subscript(expr):
252252
value: expr
253-
slice: _slice
253+
slice: _Slice
254254
ctx: expr_context
255255

256256
class Name(expr):
257-
id: _identifier
257+
id: _Identifier
258258
ctx: expr_context
259259

260260
class List(expr):
@@ -319,18 +319,18 @@ class ExceptHandler(AST):
319319

320320
class arguments(AST):
321321
args: list[expr]
322-
vararg: _identifier | None
323-
kwarg: _identifier | None
322+
vararg: _Identifier | None
323+
kwarg: _Identifier | None
324324
defaults: list[expr]
325325
type_comments: list[str | None]
326326

327327
class keyword(AST):
328-
arg: _identifier
328+
arg: _Identifier
329329
value: expr
330330

331331
class alias(AST):
332-
name: _identifier
333-
asname: _identifier | None
332+
name: _Identifier
333+
asname: _Identifier | None
334334

335335
class TypeIgnore(AST):
336336
lineno: int

0 commit comments

Comments
 (0)
0