Skip to content

Commit 7115807

Browse files
authored
Enable pyright for all Python 3 stubs (#5597)
* pyright: disable reportUnknownParameterType Unknown parameter types are preferred over Any annotations for incomplete stubs. Especially larger stubs are expected to be incomplete for some time and it would be a shame to lose the other pyright warnings for those stubs. * Also disable reportUnknownVariableType Fix problems with tkinter * Disable reportUnknownMemberType Fix pyright problems
1 parent c601d5c commit 7115807

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+633
-687
lines changed

pyrightconfig.json

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,7 @@
1717
"stubs/pymssql",
1818
"stubs/Routes",
1919
"stubs/scribe",
20-
"stubs/tornado",
21-
// Modules that are incomplete in some way.
22-
"stdlib/sqlite3/dbapi2.pyi",
23-
"stdlib/tkinter",
24-
"stdlib/xml/dom",
25-
"stdlib/xml/sax",
26-
"stubs/backports",
27-
"stubs/backports_abc",
28-
"stubs/boto",
29-
"stubs/cryptography",
30-
"stubs/docutils",
31-
"stubs/Flask",
32-
"stubs/Jinja2",
33-
"stubs/Markdown",
34-
"stubs/paramiko",
35-
"stubs/protobuf",
36-
"stubs/PyMySQL",
37-
"stubs/python-dateutil",
38-
"stubs/pyvmomi",
39-
"stubs/PyYAML",
40-
"stubs/redis",
41-
"stubs/requests",
42-
"stubs/simplejson",
43-
"stubs/waitress",
44-
"stubs/Werkzeug"
20+
"stubs/tornado"
4521
],
4622
"typeCheckingMode": "basic",
4723
"strictListInference": true,
@@ -70,11 +46,8 @@
7046
"reportIncompatibleMethodOverride": "error",
7147
"reportIncompatibleVariableOverride": "error",
7248
"reportInvalidStringEscapeSequence": "error",
73-
"reportUnknownParameterType": "error",
7449
"reportUnknownArgumentType": "error",
7550
"reportUnknownLambdaType": "error",
76-
"reportUnknownVariableType": "error",
77-
"reportUnknownMemberType": "error",
7851
"reportMissingTypeArgument": "error",
7952
"reportUndefinedVariable": "error",
8053
"reportUnboundVariable": "error",

stdlib/tkinter/__init__.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,11 @@ class EventType(str, Enum):
164164
VirtualEvent: str = ...
165165
Visibility: str = ...
166166

167+
_W = TypeVar("_W", bound="Misc")
167168
# Events considered covariant because you should never assign to event.widget.
168-
_W = TypeVar("_W", covariant=True, bound="Misc")
169+
_W_co = TypeVar("_W_co", covariant=True, bound="Misc")
169170

170-
class Event(Generic[_W]):
171+
class Event(Generic[_W_co]):
171172
serial: int
172173
num: int
173174
focus: bool
@@ -185,7 +186,7 @@ class Event(Generic[_W]):
185186
keysym: str
186187
keysym_num: int
187188
type: EventType
188-
widget: _W
189+
widget: _W_co
189190
delta: int
190191

191192
def NoDefaultRoot(): ...

stdlib/tkinter/font.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
import tkinter
3-
from typing import Any, List, Optional, Tuple, TypeVar, Union, overload
3+
from typing import Any, Optional, Tuple, Union, overload
44
from typing_extensions import Literal, TypedDict
55

66
NORMAL: Literal["normal"]

stdlib/tkinter/scrolledtext.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from tkinter import Frame, Grid, Misc, Pack, Place, Scrollbar, Text
1+
from tkinter import Frame, Misc, Scrollbar, Text
22
from typing import Any, Optional
33

44
# The methods from Pack, Place, and Grid are dynamically added over the parent's impls

stdlib/tkinter/ttk.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _tkinter
22
import sys
33
import tkinter
44
from tkinter.font import _FontDescription
5-
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, overload
5+
from typing import Any, Callable, Dict, Optional, Tuple, Union, overload
66
from typing_extensions import Literal, TypedDict
77

88
def tclobjs_to_py(adict): ...

stubs/Jinja2/jinja2/utils.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ concat: Any
1010

1111
_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
1212

13-
class _ContextFunction(Protocol[_CallableT]):
13+
class _ContextFunction(Protocol[_CallableT]): # type: ignore
1414
contextfunction: Literal[True]
1515
__call__: _CallableT
1616

17-
class _EvalContextFunction(Protocol[_CallableT]):
17+
class _EvalContextFunction(Protocol[_CallableT]): # type: ignore
1818
evalcontextfunction: Literal[True]
1919
__call__: _CallableT
2020

21-
class _EnvironmentFunction(Protocol[_CallableT]):
21+
class _EnvironmentFunction(Protocol[_CallableT]): # type: ignore
2222
environmentfunction: Literal[True]
2323
__call__: _CallableT
2424

stubs/Markdown/markdown/blockparser.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Any
1+
from typing import Any, List
22

3-
class State(list):
3+
class State(List[Any]):
44
def set(self, state) -> None: ...
55
def reset(self) -> None: ...
66
def isstate(self, state): ...

stubs/Markdown/markdown/blockprocessors.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,42 @@ class BlockProcessor:
1717
class ListIndentProcessor(BlockProcessor):
1818
ITEM_TYPES: Any
1919
LIST_TYPES: Any
20-
INDENT_RE: Pattern
20+
INDENT_RE: Pattern[str]
2121
def __init__(self, *args) -> None: ...
2222
def create_item(self, parent, block) -> None: ...
2323
def get_level(self, parent, block): ...
2424

2525
class CodeBlockProcessor(BlockProcessor): ...
2626

2727
class BlockQuoteProcessor(BlockProcessor):
28-
RE: Pattern
28+
RE: Pattern[str]
2929
def clean(self, line): ...
3030

3131
class OListProcessor(BlockProcessor):
3232
TAG: str = ...
3333
STARTSWITH: str = ...
3434
LAZY_OL: bool = ...
3535
SIBLING_TAGS: Any
36-
RE: Pattern
37-
CHILD_RE: Pattern
38-
INDENT_RE: Pattern
36+
RE: Pattern[str]
37+
CHILD_RE: Pattern[str]
38+
INDENT_RE: Pattern[str]
3939
def __init__(self, parser) -> None: ...
4040
def get_items(self, block): ...
4141

4242
class UListProcessor(OListProcessor):
4343
TAG: str = ...
44-
RE: Pattern
44+
RE: Pattern[str]
4545
def __init__(self, parser) -> None: ...
4646

4747
class HashHeaderProcessor(BlockProcessor):
48-
RE: Pattern
48+
RE: Pattern[str]
4949

5050
class SetextHeaderProcessor(BlockProcessor):
51-
RE: Pattern
51+
RE: Pattern[str]
5252

5353
class HRProcessor(BlockProcessor):
5454
RE: str = ...
55-
SEARCH_RE: Pattern
55+
SEARCH_RE: Pattern[str]
5656
match: Any
5757

5858
class EmptyBlockProcessor(BlockProcessor): ...

stubs/Markdown/markdown/extensions/abbr.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from markdown.blockprocessors import BlockProcessor
44
from markdown.extensions import Extension
55
from markdown.inlinepatterns import InlineProcessor
66

7-
ABBR_REF_RE: Pattern
7+
ABBR_REF_RE: Pattern[str]
88

99
class AbbrExtension(Extension): ...
1010
class AbbrPreprocessor(BlockProcessor): ...

stubs/Markdown/markdown/extensions/admonition.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ from markdown.extensions import Extension
66
class AdmonitionExtension(Extension): ...
77

88
class AdmonitionProcessor(BlockProcessor):
9-
CLASSNAME: str = ...
10-
CLASSNAME_TITLE: str = ...
11-
RE: Pattern
9+
CLASSNAME: str
10+
CLASSNAME_TITLE: str
11+
RE: Pattern[str]
1212
RE_SPACES: Any
1313
def get_class_and_title(self, match): ...
1414

0 commit comments

Comments
 (0)