Skip to content

Commit fbddd2c

Browse files
authored
stdlib: enforce CamelCase for type alias names (#8255)
1 parent abea36c commit fbddd2c

11 files changed

+107
-108
lines changed

stdlib/_ast.pyi

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if sys.version_info >= (3, 8):
77
PyCF_TYPE_COMMENTS: Literal[4096]
88
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
99

10-
_identifier: TypeAlias = str
10+
_Identifier: TypeAlias = str
1111

1212
class AST:
1313
if sys.version_info >= (3, 10):
@@ -61,7 +61,7 @@ class stmt(AST): ...
6161
class FunctionDef(stmt):
6262
if sys.version_info >= (3, 10):
6363
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
64-
name: _identifier
64+
name: _Identifier
6565
args: arguments
6666
body: list[stmt]
6767
decorator_list: list[expr]
@@ -70,7 +70,7 @@ class FunctionDef(stmt):
7070
class AsyncFunctionDef(stmt):
7171
if sys.version_info >= (3, 10):
7272
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
73-
name: _identifier
73+
name: _Identifier
7474
args: arguments
7575
body: list[stmt]
7676
decorator_list: list[expr]
@@ -79,7 +79,7 @@ class AsyncFunctionDef(stmt):
7979
class ClassDef(stmt):
8080
if sys.version_info >= (3, 10):
8181
__match_args__ = ("name", "bases", "keywords", "body", "decorator_list")
82-
name: _identifier
82+
name: _Identifier
8383
bases: list[expr]
8484
keywords: list[keyword]
8585
body: list[stmt]
@@ -194,19 +194,19 @@ class Import(stmt):
194194
class ImportFrom(stmt):
195195
if sys.version_info >= (3, 10):
196196
__match_args__ = ("module", "names", "level")
197-
module: _identifier | None
197+
module: _Identifier | None
198198
names: list[alias]
199199
level: int
200200

201201
class Global(stmt):
202202
if sys.version_info >= (3, 10):
203203
__match_args__ = ("names",)
204-
names: list[_identifier]
204+
names: list[_Identifier]
205205

206206
class Nonlocal(stmt):
207207
if sys.version_info >= (3, 10):
208208
__match_args__ = ("names",)
209-
names: list[_identifier]
209+
names: list[_Identifier]
210210

211211
class Expr(stmt):
212212
if sys.version_info >= (3, 10):
@@ -362,7 +362,7 @@ class Attribute(expr):
362362
if sys.version_info >= (3, 10):
363363
__match_args__ = ("value", "attr", "ctx")
364364
value: expr
365-
attr: _identifier
365+
attr: _Identifier
366366
ctx: expr_context
367367

368368
if sys.version_info >= (3, 9):
@@ -401,7 +401,7 @@ class Starred(expr):
401401
class Name(expr):
402402
if sys.version_info >= (3, 10):
403403
__match_args__ = ("id", "ctx")
404-
id: _identifier
404+
id: _Identifier
405405
ctx: expr_context
406406

407407
class List(expr):
@@ -479,7 +479,7 @@ class ExceptHandler(excepthandler):
479479
if sys.version_info >= (3, 10):
480480
__match_args__ = ("type", "name", "body")
481481
type: expr | None
482-
name: _identifier | None
482+
name: _Identifier | None
483483
body: list[stmt]
484484

485485
class arguments(AST):
@@ -497,20 +497,20 @@ class arguments(AST):
497497
class arg(AST):
498498
if sys.version_info >= (3, 10):
499499
__match_args__ = ("arg", "annotation", "type_comment")
500-
arg: _identifier
500+
arg: _Identifier
501501
annotation: expr | None
502502

503503
class keyword(AST):
504504
if sys.version_info >= (3, 10):
505505
__match_args__ = ("arg", "value")
506-
arg: _identifier | None
506+
arg: _Identifier | None
507507
value: expr
508508

509509
class alias(AST):
510510
if sys.version_info >= (3, 10):
511511
__match_args__ = ("name", "asname")
512-
name: _identifier
513-
asname: _identifier | None
512+
name: _Identifier
513+
asname: _Identifier | None
514514

515515
class withitem(AST):
516516
if sys.version_info >= (3, 10):
@@ -526,11 +526,11 @@ if sys.version_info >= (3, 10):
526526

527527
class pattern(AST): ...
528528
# Without the alias, Pyright complains variables named pattern are recursively defined
529-
_pattern: TypeAlias = pattern
529+
_Pattern: TypeAlias = pattern
530530

531531
class match_case(AST):
532532
__match_args__ = ("pattern", "guard", "body")
533-
pattern: _pattern
533+
pattern: _Pattern
534534
guard: expr | None
535535
body: list[stmt]
536536

@@ -548,25 +548,25 @@ if sys.version_info >= (3, 10):
548548

549549
class MatchStar(pattern):
550550
__match_args__ = ("name",)
551-
name: _identifier | None
551+
name: _Identifier | None
552552

553553
class MatchMapping(pattern):
554554
__match_args__ = ("keys", "patterns", "rest")
555555
keys: list[expr]
556556
patterns: list[pattern]
557-
rest: _identifier | None
557+
rest: _Identifier | None
558558

559559
class MatchClass(pattern):
560560
__match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns")
561561
cls: expr
562562
patterns: list[pattern]
563-
kwd_attrs: list[_identifier]
563+
kwd_attrs: list[_Identifier]
564564
kwd_patterns: list[pattern]
565565

566566
class MatchAs(pattern):
567567
__match_args__ = ("pattern", "name")
568-
pattern: _pattern | None
569-
name: _identifier | None
568+
pattern: _Pattern | None
569+
name: _Identifier | None
570570

571571
class MatchOr(pattern):
572572
__match_args__ = ("patterns",)

stdlib/_curses.pyi

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from typing import IO, Any, NamedTuple, overload
44
from typing_extensions import TypeAlias, final
55

66
if sys.platform != "win32":
7-
_chtype: TypeAlias = str | bytes | int
7+
_ChType: TypeAlias = str | bytes | int
88

99
# ACS codes are only initialized after initscr is called
1010
ACS_BBSS: int
@@ -365,9 +365,9 @@ if sys.platform != "win32":
365365
__i9: int = ...,
366366
) -> bytes: ...
367367
def typeahead(__fd: int) -> None: ...
368-
def unctrl(__ch: _chtype) -> bytes: ...
368+
def unctrl(__ch: _ChType) -> bytes: ...
369369
def unget_wch(__ch: int | str) -> None: ...
370-
def ungetch(__ch: _chtype) -> None: ...
370+
def ungetch(__ch: _ChType) -> None: ...
371371
def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ...
372372
def update_lines_cols() -> None: ...
373373
def use_default_colors() -> None: ...
@@ -379,9 +379,9 @@ if sys.platform != "win32":
379379
class _CursesWindow:
380380
encoding: str
381381
@overload
382-
def addch(self, ch: _chtype, attr: int = ...) -> None: ...
382+
def addch(self, ch: _ChType, attr: int = ...) -> None: ...
383383
@overload
384-
def addch(self, y: int, x: int, ch: _chtype, attr: int = ...) -> None: ...
384+
def addch(self, y: int, x: int, ch: _ChType, attr: int = ...) -> None: ...
385385
@overload
386386
def addnstr(self, str: str, n: int, attr: int = ...) -> None: ...
387387
@overload
@@ -393,23 +393,23 @@ if sys.platform != "win32":
393393
def attroff(self, __attr: int) -> None: ...
394394
def attron(self, __attr: int) -> None: ...
395395
def attrset(self, __attr: int) -> None: ...
396-
def bkgd(self, __ch: _chtype, __attr: int = ...) -> None: ...
397-
def bkgdset(self, __ch: _chtype, __attr: int = ...) -> None: ...
396+
def bkgd(self, __ch: _ChType, __attr: int = ...) -> None: ...
397+
def bkgdset(self, __ch: _ChType, __attr: int = ...) -> None: ...
398398
def border(
399399
self,
400-
ls: _chtype = ...,
401-
rs: _chtype = ...,
402-
ts: _chtype = ...,
403-
bs: _chtype = ...,
404-
tl: _chtype = ...,
405-
tr: _chtype = ...,
406-
bl: _chtype = ...,
407-
br: _chtype = ...,
400+
ls: _ChType = ...,
401+
rs: _ChType = ...,
402+
ts: _ChType = ...,
403+
bs: _ChType = ...,
404+
tl: _ChType = ...,
405+
tr: _ChType = ...,
406+
bl: _ChType = ...,
407+
br: _ChType = ...,
408408
) -> None: ...
409409
@overload
410410
def box(self) -> None: ...
411411
@overload
412-
def box(self, vertch: _chtype = ..., horch: _chtype = ...) -> None: ...
412+
def box(self, vertch: _ChType = ..., horch: _ChType = ...) -> None: ...
413413
@overload
414414
def chgat(self, attr: int) -> None: ...
415415
@overload
@@ -432,7 +432,7 @@ if sys.platform != "win32":
432432
def derwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
433433
@overload
434434
def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
435-
def echochar(self, __ch: _chtype, __attr: int = ...) -> None: ...
435+
def echochar(self, __ch: _ChType, __attr: int = ...) -> None: ...
436436
def enclose(self, __y: int, __x: int) -> bool: ...
437437
def erase(self) -> None: ...
438438
def getbegyx(self) -> tuple[int, int]: ...
@@ -461,9 +461,9 @@ if sys.platform != "win32":
461461
def getstr(self, y: int, x: int, n: int) -> bytes: ...
462462
def getyx(self) -> tuple[int, int]: ...
463463
@overload
464-
def hline(self, ch: _chtype, n: int) -> None: ...
464+
def hline(self, ch: _ChType, n: int) -> None: ...
465465
@overload
466-
def hline(self, y: int, x: int, ch: _chtype, n: int) -> None: ...
466+
def hline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
467467
def idcok(self, flag: bool) -> None: ...
468468
def idlok(self, yes: bool) -> None: ...
469469
def immedok(self, flag: bool) -> None: ...
@@ -472,9 +472,9 @@ if sys.platform != "win32":
472472
@overload
473473
def inch(self, y: int, x: int) -> int: ...
474474
@overload
475-
def insch(self, ch: _chtype, attr: int = ...) -> None: ...
475+
def insch(self, ch: _ChType, attr: int = ...) -> None: ...
476476
@overload
477-
def insch(self, y: int, x: int, ch: _chtype, attr: int = ...) -> None: ...
477+
def insch(self, y: int, x: int, ch: _ChType, attr: int = ...) -> None: ...
478478
def insdelln(self, nlines: int) -> None: ...
479479
def insertln(self) -> None: ...
480480
@overload
@@ -543,9 +543,9 @@ if sys.platform != "win32":
543543
def touchwin(self) -> None: ...
544544
def untouchwin(self) -> None: ...
545545
@overload
546-
def vline(self, ch: _chtype, n: int) -> None: ...
546+
def vline(self, ch: _ChType, n: int) -> None: ...
547547
@overload
548-
def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ...
548+
def vline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
549549
if sys.version_info >= (3, 8):
550550
class _ncurses_version(NamedTuple):
551551
major: int

stdlib/_threading_local.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ from typing_extensions import TypeAlias
33
from weakref import ReferenceType
44

55
__all__ = ["local"]
6-
_localdict: TypeAlias = dict[Any, Any]
6+
_LocalDict: TypeAlias = dict[Any, Any]
77

88
class _localimpl:
99
key: str
10-
dicts: dict[int, tuple[ReferenceType[Any], _localdict]]
10+
dicts: dict[int, tuple[ReferenceType[Any], _LocalDict]]
1111
def __init__(self) -> None: ...
12-
def get_dict(self) -> _localdict: ...
13-
def create_dict(self) -> _localdict: ...
12+
def get_dict(self) -> _LocalDict: ...
13+
def create_dict(self) -> _LocalDict: ...
1414

1515
class local:
1616
def __getattribute__(self, name: str) -> Any: ...

stdlib/asynchat.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class simple_producer:
99
class async_chat(asyncore.dispatcher):
1010
ac_in_buffer_size: int
1111
ac_out_buffer_size: int
12-
def __init__(self, sock: socket.socket | None = ..., map: asyncore._maptype | None = ...) -> None: ...
12+
def __init__(self, sock: socket.socket | None = ..., map: asyncore._MapType | None = ...) -> None: ...
1313
@abstractmethod
1414
def collect_incoming_data(self, data: bytes) -> None: ...
1515
@abstractmethod

stdlib/asyncore.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ from typing import Any, overload
55
from typing_extensions import TypeAlias
66

77
# cyclic dependence with asynchat
8-
_maptype: TypeAlias = dict[int, Any]
9-
_socket: TypeAlias = socket
8+
_MapType: TypeAlias = dict[int, Any]
9+
_Socket: TypeAlias = socket
1010

11-
socket_map: _maptype # undocumented
11+
socket_map: _MapType # undocumented
1212

1313
class ExitNow(Exception): ...
1414

1515
def read(obj: Any) -> None: ...
1616
def write(obj: Any) -> None: ...
1717
def readwrite(obj: Any, flags: int) -> None: ...
18-
def poll(timeout: float = ..., map: _maptype | None = ...) -> None: ...
19-
def poll2(timeout: float = ..., map: _maptype | None = ...) -> None: ...
18+
def poll(timeout: float = ..., map: _MapType | None = ...) -> None: ...
19+
def poll2(timeout: float = ..., map: _MapType | None = ...) -> None: ...
2020

2121
poll3 = poll2
2222

23-
def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype | None = ..., count: int | None = ...) -> None: ...
23+
def loop(timeout: float = ..., use_poll: bool = ..., map: _MapType | None = ..., count: int | None = ...) -> None: ...
2424

2525
# Not really subclass of socket.socket; it's only delegation.
2626
# It is not covariant to it.
@@ -32,19 +32,19 @@ class dispatcher:
3232
connecting: bool
3333
closing: bool
3434
ignore_log_types: frozenset[str]
35-
socket: _socket | None
36-
def __init__(self, sock: _socket | None = ..., map: _maptype | None = ...) -> None: ...
37-
def add_channel(self, map: _maptype | None = ...) -> None: ...
38-
def del_channel(self, map: _maptype | None = ...) -> None: ...
35+
socket: _Socket | None
36+
def __init__(self, sock: _Socket | None = ..., map: _MapType | None = ...) -> None: ...
37+
def add_channel(self, map: _MapType | None = ...) -> None: ...
38+
def del_channel(self, map: _MapType | None = ...) -> None: ...
3939
def create_socket(self, family: int = ..., type: int = ...) -> None: ...
40-
def set_socket(self, sock: _socket, map: _maptype | None = ...) -> None: ...
40+
def set_socket(self, sock: _Socket, map: _MapType | None = ...) -> None: ...
4141
def set_reuse_addr(self) -> None: ...
4242
def readable(self) -> bool: ...
4343
def writable(self) -> bool: ...
4444
def listen(self, num: int) -> None: ...
4545
def bind(self, addr: tuple[Any, ...] | str) -> None: ...
4646
def connect(self, address: tuple[Any, ...] | str) -> None: ...
47-
def accept(self) -> tuple[_socket, Any] | None: ...
47+
def accept(self) -> tuple[_Socket, Any] | None: ...
4848
def send(self, data: bytes) -> int: ...
4949
def recv(self, buffer_size: int) -> bytes: ...
5050
def close(self) -> None: ...
@@ -63,14 +63,14 @@ class dispatcher:
6363
def handle_close(self) -> None: ...
6464

6565
class dispatcher_with_send(dispatcher):
66-
def __init__(self, sock: socket | None = ..., map: _maptype | None = ...) -> None: ...
66+
def __init__(self, sock: socket | None = ..., map: _MapType | None = ...) -> None: ...
6767
def initiate_send(self) -> None: ...
6868
def handle_write(self) -> None: ...
6969
# incompatible signature:
7070
# def send(self, data: bytes) -> int | None: ...
7171

7272
def compact_traceback() -> tuple[tuple[str, str, str], type, type, str]: ...
73-
def close_all(map: _maptype | None = ..., ignore_all: bool = ...) -> None: ...
73+
def close_all(map: _MapType | None = ..., ignore_all: bool = ...) -> None: ...
7474

7575
if sys.platform != "win32":
7676
class file_wrapper:
@@ -88,5 +88,5 @@ if sys.platform != "win32":
8888
def fileno(self) -> int: ...
8989

9090
class file_dispatcher(dispatcher):
91-
def __init__(self, fd: FileDescriptorLike, map: _maptype | None = ...) -> None: ...
91+
def __init__(self, fd: FileDescriptorLike, map: _MapType | None = ...) -> None: ...
9292
def set_file(self, fd: int) -> None: ...

0 commit comments

Comments
 (0)