Skip to content

Commit 0125fe2

Browse files
authored
Replace Incomplete | None = None in stdlib (#14083)
1 parent 5785616 commit 0125fe2

File tree

12 files changed

+50
-62
lines changed

12 files changed

+50
-62
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def foo(x): ... # unannotated argument and return type
312312
`Incomplete` can also be used for partially known types:
313313

314314
```python
315-
def foo(x: Incomplete | None = None) -> list[Incomplete]: ...
315+
def foo(x: Incomplete | None) -> list[Incomplete]: ...
316316
```
317317

318318
### What to do when a project's documentation and implementation disagree

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// test cases use a custom pyrightconfig file
1010
"**/@tests/test_cases",
1111
"stdlib/__main__.pyi",
12+
"stdlib/distutils/cmd.pyi",
1213
"stdlib/distutils/command",
1314
"stdlib/distutils/dist.pyi",
1415
"stdlib/encodings/__init__.pyi",

stdlib/distutils/cmd.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused
1+
from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused
22
from abc import abstractmethod
33
from collections.abc import Callable, Iterable
44
from distutils.command.bdist import bdist
@@ -226,4 +226,4 @@ class Command:
226226
level: Unused = 1,
227227
) -> None: ...
228228
def ensure_finalized(self) -> None: ...
229-
def dump_options(self, header: Incomplete | None = None, indent: str = "") -> None: ...
229+
def dump_options(self, header=None, indent: str = "") -> None: ...

stdlib/distutils/command/config.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Incomplete, StrOrBytesPath
1+
from _typeshed import StrOrBytesPath
22
from collections.abc import Sequence
33
from re import Pattern
44
from typing import ClassVar, Final, Literal
@@ -81,4 +81,4 @@ class config(Command):
8181
self, header: str, include_dirs: Sequence[str] | None = None, library_dirs: Sequence[str] | None = None, lang: str = "c"
8282
) -> bool: ...
8383

84-
def dump_file(filename: StrOrBytesPath, head: Incomplete | None = None) -> None: ...
84+
def dump_file(filename: StrOrBytesPath, head=None) -> None: ...

stdlib/distutils/command/register.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from _typeshed import Incomplete
21
from collections.abc import Callable
32
from typing import Any, ClassVar
43

@@ -18,4 +17,4 @@ class register(PyPIRCCommand):
1817
def verify_metadata(self) -> None: ...
1918
def send_metadata(self) -> None: ...
2019
def build_post_data(self, action): ...
21-
def post_to_server(self, data, auth: Incomplete | None = None): ...
20+
def post_to_server(self, data, auth=None): ...

stdlib/distutils/dist.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ class Distribution:
112112
command_obj: Incomplete
113113
have_run: Incomplete
114114
want_user_cfg: bool
115-
def dump_option_dicts(
116-
self, header: Incomplete | None = None, commands: Incomplete | None = None, indent: str = ""
117-
) -> None: ...
115+
def dump_option_dicts(self, header=None, commands=None, indent: str = "") -> None: ...
118116
def find_config_files(self): ...
119117
commands: Incomplete
120118
def parse_command_line(self): ...

stdlib/numbers.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# (since type checkers don't see `complex` as a subtype of `numbers.Complex`,
88
# nor `float` as a subtype of `numbers.Real`, etc.)
99

10-
from _typeshed import Incomplete
1110
from abc import ABCMeta, abstractmethod
1211
from typing import ClassVar, Literal, Protocol, overload
1312

@@ -166,7 +165,7 @@ class Integral(Rational, _IntegralLike):
166165
def __int__(self) -> int: ...
167166
def __index__(self) -> int: ...
168167
@abstractmethod
169-
def __pow__(self, exponent, modulus: Incomplete | None = None) -> _IntegralLike: ...
168+
def __pow__(self, exponent, modulus=None) -> _IntegralLike: ...
170169
@abstractmethod
171170
def __lshift__(self, other) -> _IntegralLike: ...
172171
@abstractmethod

stdlib/tkinter/__init__.pyi

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class Event(Generic[_W_co]):
312312
def NoDefaultRoot() -> None: ...
313313

314314
class Variable:
315-
def __init__(self, master: Misc | None = None, value: Incomplete | None = None, name: str | None = None) -> None: ...
315+
def __init__(self, master: Misc | None = None, value=None, name: str | None = None) -> None: ...
316316
def set(self, value) -> None: ...
317317
initialize = set
318318
def get(self): ...
@@ -379,7 +379,7 @@ class Misc:
379379
children: dict[str, Widget]
380380
def destroy(self) -> None: ...
381381
def deletecommand(self, name: str) -> None: ...
382-
def tk_strictMotif(self, boolean: Incomplete | None = None): ...
382+
def tk_strictMotif(self, boolean=None): ...
383383
def tk_bisque(self) -> None: ...
384384
def tk_setPalette(self, *args, **kw) -> None: ...
385385
def wait_variable(self, name: str | Variable = "PY_VAR") -> None: ...
@@ -442,15 +442,15 @@ class Misc:
442442
) -> None: ...
443443
def option_clear(self) -> None: ...
444444
def option_get(self, name, className): ...
445-
def option_readfile(self, fileName, priority: Incomplete | None = None) -> None: ...
445+
def option_readfile(self, fileName, priority=None) -> None: ...
446446
def selection_clear(self, **kw) -> None: ...
447447
def selection_get(self, **kw): ...
448448
def selection_handle(self, command, **kw) -> None: ...
449449
def selection_own(self, **kw) -> None: ...
450450
def selection_own_get(self, **kw): ...
451451
def send(self, interp, cmd, *args): ...
452-
def lower(self, belowThis: Incomplete | None = None) -> None: ...
453-
def tkraise(self, aboveThis: Incomplete | None = None) -> None: ...
452+
def lower(self, belowThis=None) -> None: ...
453+
def tkraise(self, aboveThis=None) -> None: ...
454454
lift = tkraise
455455
if sys.version_info >= (3, 11):
456456
def info_patchlevel(self) -> _VersionInfoType: ...
@@ -888,29 +888,23 @@ class Wm:
888888
@overload
889889
def wm_geometry(self, newGeometry: str) -> None: ...
890890
geometry = wm_geometry
891-
def wm_grid(
892-
self,
893-
baseWidth: Incomplete | None = None,
894-
baseHeight: Incomplete | None = None,
895-
widthInc: Incomplete | None = None,
896-
heightInc: Incomplete | None = None,
897-
): ...
891+
def wm_grid(self, baseWidth=None, baseHeight=None, widthInc=None, heightInc=None): ...
898892
grid = wm_grid
899-
def wm_group(self, pathName: Incomplete | None = None): ...
893+
def wm_group(self, pathName=None): ...
900894
group = wm_group
901-
def wm_iconbitmap(self, bitmap: Incomplete | None = None, default: Incomplete | None = None): ...
895+
def wm_iconbitmap(self, bitmap=None, default=None): ...
902896
iconbitmap = wm_iconbitmap
903897
def wm_iconify(self) -> None: ...
904898
iconify = wm_iconify
905-
def wm_iconmask(self, bitmap: Incomplete | None = None): ...
899+
def wm_iconmask(self, bitmap=None): ...
906900
iconmask = wm_iconmask
907-
def wm_iconname(self, newName: Incomplete | None = None) -> str: ...
901+
def wm_iconname(self, newName=None) -> str: ...
908902
iconname = wm_iconname
909903
def wm_iconphoto(self, default: bool, image1: _PhotoImageLike | str, /, *args: _PhotoImageLike | str) -> None: ...
910904
iconphoto = wm_iconphoto
911905
def wm_iconposition(self, x: int | None = None, y: int | None = None) -> tuple[int, int] | None: ...
912906
iconposition = wm_iconposition
913-
def wm_iconwindow(self, pathName: Incomplete | None = None): ...
907+
def wm_iconwindow(self, pathName=None): ...
914908
iconwindow = wm_iconwindow
915909
def wm_manage(self, widget) -> None: ...
916910
manage = wm_manage
@@ -1453,8 +1447,8 @@ class Canvas(Widget, XView, YView):
14531447
@overload
14541448
def tag_bind(self, tagOrId: str | int, *, func: str, add: Literal["", "+"] | bool | None = None) -> None: ...
14551449
def tag_unbind(self, tagOrId: str | int, sequence: str, funcid: str | None = None) -> None: ...
1456-
def canvasx(self, screenx, gridspacing: Incomplete | None = None): ...
1457-
def canvasy(self, screeny, gridspacing: Incomplete | None = None): ...
1450+
def canvasx(self, screenx, gridspacing=None): ...
1451+
def canvasy(self, screeny, gridspacing=None): ...
14581452
@overload
14591453
def coords(self, tagOrId: str | int, /) -> list[float]: ...
14601454
@overload
@@ -2462,7 +2456,7 @@ class Listbox(Widget, XView, YView):
24622456
select_set = selection_set
24632457
def size(self) -> int: ... # type: ignore[override]
24642458
def itemcget(self, index: str | int, option): ...
2465-
def itemconfigure(self, index: str | int, cnf: Incomplete | None = None, **kw): ...
2459+
def itemconfigure(self, index: str | int, cnf=None, **kw): ...
24662460
itemconfig = itemconfigure
24672461

24682462
class Menu(Widget):
@@ -3142,7 +3136,7 @@ class Scrollbar(Widget):
31423136
@overload
31433137
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
31443138
config = configure
3145-
def activate(self, index: Incomplete | None = None): ...
3139+
def activate(self, index=None): ...
31463140
def delta(self, deltax: int, deltay: int) -> float: ...
31473141
def fraction(self, x: int, y: int) -> float: ...
31483142
def identify(self, x: int, y: int) -> Literal["arrow1", "arrow2", "slider", "trough1", "trough2", ""]: ...
@@ -3625,7 +3619,7 @@ class Text(Widget, XView, YView):
36253619
def yview_pickplace(self, *what): ... # deprecated
36263620

36273621
class _setit:
3628-
def __init__(self, var, value, callback: Incomplete | None = None) -> None: ...
3622+
def __init__(self, var, value, callback=None) -> None: ...
36293623
def __call__(self, *args) -> None: ...
36303624

36313625
# manual page: tk_optionMenu
@@ -3663,9 +3657,7 @@ class _PhotoImageLike(_Image): ...
36633657
class Image(_Image):
36643658
name: Incomplete
36653659
tk: _tkinter.TkappType
3666-
def __init__(
3667-
self, imgtype, name: Incomplete | None = None, cnf={}, master: Misc | _tkinter.TkappType | None = None, **kw
3668-
) -> None: ...
3660+
def __init__(self, imgtype, name=None, cnf={}, master: Misc | _tkinter.TkappType | None = None, **kw) -> None: ...
36693661
def __del__(self) -> None: ...
36703662
def __setitem__(self, key, value) -> None: ...
36713663
def __getitem__(self, key): ...
@@ -3791,7 +3783,7 @@ class BitmapImage(Image, _BitmapImageLike):
37913783
# This should be kept in sync with PIL.ImageTK.BitmapImage.__init__()
37923784
def __init__(
37933785
self,
3794-
name: Incomplete | None = None,
3786+
name=None,
37953787
cnf: dict[str, Any] = {},
37963788
master: Misc | _tkinter.TkappType | None = None,
37973789
*,
@@ -3925,7 +3917,7 @@ class Spinbox(Widget, XView):
39253917
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
39263918
config = configure
39273919
def bbox(self, index) -> tuple[int, int, int, int] | None: ... # type: ignore[override]
3928-
def delete(self, first, last: Incomplete | None = None) -> Literal[""]: ...
3920+
def delete(self, first, last=None) -> Literal[""]: ...
39293921
def get(self) -> str: ...
39303922
def icursor(self, index): ...
39313923
def identify(self, x: int, y: int) -> Literal["", "buttondown", "buttonup", "entry"]: ...
@@ -3939,7 +3931,7 @@ class Spinbox(Widget, XView):
39393931
def selection(self, *args) -> tuple[int, ...]: ...
39403932
def selection_adjust(self, index): ...
39413933
def selection_clear(self): ... # type: ignore[override]
3942-
def selection_element(self, element: Incomplete | None = None): ...
3934+
def selection_element(self, element=None): ...
39433935
def selection_from(self, index: int) -> None: ...
39443936
def selection_present(self) -> None: ...
39453937
def selection_range(self, start: int, end: int) -> None: ...
@@ -4082,7 +4074,7 @@ class PanedWindow(Widget):
40824074
def sash_mark(self, index): ...
40834075
def sash_place(self, index, x, y): ...
40844076
def panecget(self, child, option): ...
4085-
def paneconfigure(self, tagOrId, cnf: Incomplete | None = None, **kw): ...
4077+
def paneconfigure(self, tagOrId, cnf=None, **kw): ...
40864078
paneconfig: Incomplete
40874079
def panes(self): ...
40884080

stdlib/tkinter/commondialog.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ class Dialog:
88
command: ClassVar[str | None]
99
master: Incomplete | None
1010
options: Mapping[str, Incomplete]
11-
def __init__(self, master: Incomplete | None = None, **options) -> None: ...
11+
def __init__(self, master=None, **options) -> None: ...
1212
def show(self, **options): ...

stdlib/tkinter/dialog.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from _typeshed import Incomplete
21
from collections.abc import Mapping
32
from tkinter import Widget
43
from typing import Any, Final
@@ -10,5 +9,5 @@ DIALOG_ICON: Final = "questhead"
109
class Dialog(Widget):
1110
widgetName: str
1211
num: int
13-
def __init__(self, master: Incomplete | None = None, cnf: Mapping[str, Any] = {}, **kw) -> None: ...
12+
def __init__(self, master=None, cnf: Mapping[str, Any] = {}, **kw) -> None: ...
1413
def destroy(self) -> None: ...

0 commit comments

Comments
 (0)