Skip to content

Enable pyright for all Python 3 stubs #5597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,7 @@
"stubs/pymssql",
"stubs/Routes",
"stubs/scribe",
"stubs/tornado",
// Modules that are incomplete in some way.
"stdlib/sqlite3/dbapi2.pyi",
"stdlib/tkinter",
"stdlib/xml/dom",
"stdlib/xml/sax",
"stubs/backports",
"stubs/backports_abc",
"stubs/boto",
"stubs/cryptography",
"stubs/docutils",
"stubs/Flask",
"stubs/Jinja2",
"stubs/Markdown",
"stubs/paramiko",
"stubs/protobuf",
"stubs/PyMySQL",
"stubs/python-dateutil",
"stubs/pyvmomi",
"stubs/PyYAML",
"stubs/redis",
"stubs/requests",
"stubs/simplejson",
"stubs/waitress",
"stubs/Werkzeug"
"stubs/tornado"
],
"typeCheckingMode": "basic",
"strictListInference": true,
Expand Down Expand Up @@ -70,11 +46,8 @@
"reportIncompatibleMethodOverride": "error",
"reportIncompatibleVariableOverride": "error",
"reportInvalidStringEscapeSequence": "error",
"reportUnknownParameterType": "error",
"reportUnknownArgumentType": "error",
"reportUnknownLambdaType": "error",
"reportUnknownVariableType": "error",
"reportUnknownMemberType": "error",
"reportMissingTypeArgument": "error",
"reportUndefinedVariable": "error",
"reportUnboundVariable": "error",
Expand Down
7 changes: 4 additions & 3 deletions stdlib/tkinter/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ class EventType(str, Enum):
VirtualEvent: str = ...
Visibility: str = ...

_W = TypeVar("_W", bound="Misc")
# Events considered covariant because you should never assign to event.widget.
_W = TypeVar("_W", covariant=True, bound="Misc")
_W_co = TypeVar("_W_co", covariant=True, bound="Misc")

class Event(Generic[_W]):
class Event(Generic[_W_co]):
serial: int
num: int
focus: bool
Expand All @@ -185,7 +186,7 @@ class Event(Generic[_W]):
keysym: str
keysym_num: int
type: EventType
widget: _W
widget: _W_co
delta: int

def NoDefaultRoot(): ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tkinter/font.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import tkinter
from typing import Any, List, Optional, Tuple, TypeVar, Union, overload
from typing import Any, Optional, Tuple, Union, overload
from typing_extensions import Literal, TypedDict

NORMAL: Literal["normal"]
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tkinter/scrolledtext.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tkinter import Frame, Grid, Misc, Pack, Place, Scrollbar, Text
from tkinter import Frame, Misc, Scrollbar, Text
from typing import Any, Optional

# The methods from Pack, Place, and Grid are dynamically added over the parent's impls
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tkinter/ttk.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _tkinter
import sys
import tkinter
from tkinter.font import _FontDescription
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, overload
from typing import Any, Callable, Dict, Optional, Tuple, Union, overload
from typing_extensions import Literal, TypedDict

def tclobjs_to_py(adict): ...
Expand Down
6 changes: 3 additions & 3 deletions stubs/Jinja2/jinja2/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ concat: Any

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

class _ContextFunction(Protocol[_CallableT]):
class _ContextFunction(Protocol[_CallableT]): # type: ignore
contextfunction: Literal[True]
__call__: _CallableT

class _EvalContextFunction(Protocol[_CallableT]):
class _EvalContextFunction(Protocol[_CallableT]): # type: ignore
evalcontextfunction: Literal[True]
__call__: _CallableT

class _EnvironmentFunction(Protocol[_CallableT]):
class _EnvironmentFunction(Protocol[_CallableT]): # type: ignore
environmentfunction: Literal[True]
__call__: _CallableT

Expand Down
4 changes: 2 additions & 2 deletions stubs/Markdown/markdown/blockparser.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any
from typing import Any, List

class State(list):
class State(List[Any]):
def set(self, state) -> None: ...
def reset(self) -> None: ...
def isstate(self, state): ...
Expand Down
18 changes: 9 additions & 9 deletions stubs/Markdown/markdown/blockprocessors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,42 @@ class BlockProcessor:
class ListIndentProcessor(BlockProcessor):
ITEM_TYPES: Any
LIST_TYPES: Any
INDENT_RE: Pattern
INDENT_RE: Pattern[str]
def __init__(self, *args) -> None: ...
def create_item(self, parent, block) -> None: ...
def get_level(self, parent, block): ...

class CodeBlockProcessor(BlockProcessor): ...

class BlockQuoteProcessor(BlockProcessor):
RE: Pattern
RE: Pattern[str]
def clean(self, line): ...

class OListProcessor(BlockProcessor):
TAG: str = ...
STARTSWITH: str = ...
LAZY_OL: bool = ...
SIBLING_TAGS: Any
RE: Pattern
CHILD_RE: Pattern
INDENT_RE: Pattern
RE: Pattern[str]
CHILD_RE: Pattern[str]
INDENT_RE: Pattern[str]
def __init__(self, parser) -> None: ...
def get_items(self, block): ...

class UListProcessor(OListProcessor):
TAG: str = ...
RE: Pattern
RE: Pattern[str]
def __init__(self, parser) -> None: ...

class HashHeaderProcessor(BlockProcessor):
RE: Pattern
RE: Pattern[str]

class SetextHeaderProcessor(BlockProcessor):
RE: Pattern
RE: Pattern[str]

class HRProcessor(BlockProcessor):
RE: str = ...
SEARCH_RE: Pattern
SEARCH_RE: Pattern[str]
match: Any

class EmptyBlockProcessor(BlockProcessor): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/Markdown/markdown/extensions/abbr.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from markdown.blockprocessors import BlockProcessor
from markdown.extensions import Extension
from markdown.inlinepatterns import InlineProcessor

ABBR_REF_RE: Pattern
ABBR_REF_RE: Pattern[str]

class AbbrExtension(Extension): ...
class AbbrPreprocessor(BlockProcessor): ...
Expand Down
6 changes: 3 additions & 3 deletions stubs/Markdown/markdown/extensions/admonition.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ from markdown.extensions import Extension
class AdmonitionExtension(Extension): ...

class AdmonitionProcessor(BlockProcessor):
CLASSNAME: str = ...
CLASSNAME_TITLE: str = ...
RE: Pattern
CLASSNAME: str
CLASSNAME_TITLE: str
RE: Pattern[str]
RE_SPACES: Any
def get_class_and_title(self, match): ...

Expand Down
12 changes: 6 additions & 6 deletions stubs/Markdown/markdown/extensions/attr_list.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Pattern
from typing import Pattern

from markdown.extensions import Extension
from markdown.treeprocessors import Treeprocessor
Expand All @@ -7,11 +7,11 @@ def get_attrs(str): ...
def isheader(elem): ...

class AttrListTreeprocessor(Treeprocessor):
BASE_RE: str = ...
HEADER_RE: Pattern
BLOCK_RE: Pattern
INLINE_RE: Pattern
NAME_RE: Pattern
BASE_RE: str
HEADER_RE: Pattern[str]
BLOCK_RE: Pattern[str]
INLINE_RE: Pattern[str]
NAME_RE: Pattern[str]
def assign_attrs(self, elem, attrs) -> None: ...
def sanitize_name(self, name): ...

Expand Down
6 changes: 3 additions & 3 deletions stubs/Markdown/markdown/extensions/def_list.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Any, Pattern
from typing import Pattern

from markdown.blockprocessors import BlockProcessor, ListIndentProcessor
from markdown.extensions import Extension

class DefListProcessor(BlockProcessor):
RE: Pattern
NO_INDENT_RE: Pattern
RE: Pattern[str]
NO_INDENT_RE: Pattern[str]

class DefListIndentProcessor(ListIndentProcessor): ...
class DefListExtension(Extension): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/Markdown/markdown/extensions/fenced_code.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from markdown.preprocessors import Preprocessor
class FencedCodeExtension(Extension): ...

class FencedBlockPreprocessor(Preprocessor):
FENCED_BLOCK_RE: Pattern
FENCED_BLOCK_RE: Pattern[str]
CODE_WRAP: str = ...
LANG_TAG: str = ...
checked_for_codehilite: bool = ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/Markdown/markdown/extensions/footnotes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ from markdown.treeprocessors import Treeprocessor

FN_BACKLINK_TEXT: Any
NBSP_PLACEHOLDER: Any
DEF_RE: Pattern
TABBED_RE: Pattern
DEF_RE: Pattern[str]
TABBED_RE: Pattern[str]
RE_REF_ID: Any

class FootnoteExtension(Extension):
Expand Down
4 changes: 2 additions & 2 deletions stubs/Markdown/markdown/extensions/legacy_attrs.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any, Pattern
from typing import Pattern

from markdown.extensions import Extension
from markdown.treeprocessors import Treeprocessor

ATTR_RE: Pattern
ATTR_RE: Pattern[str]

class LegacyAttrs(Treeprocessor):
def handleAttributes(self, el, txt): ...
Expand Down
2 changes: 0 additions & 2 deletions stubs/Markdown/markdown/extensions/legacy_em.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any

from markdown.extensions import Extension
from markdown.inlinepatterns import UnderscoreProcessor

Expand Down
2 changes: 0 additions & 2 deletions stubs/Markdown/markdown/extensions/md_in_html.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any, Optional

from markdown.blockprocessors import BlockProcessor
from markdown.extensions import Extension

Expand Down
8 changes: 4 additions & 4 deletions stubs/Markdown/markdown/extensions/meta.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ from markdown.extensions import Extension
from markdown.preprocessors import Preprocessor

log: Any
META_RE: Pattern
META_MORE_RE: Pattern
BEGIN_RE: Pattern
END_RE: Pattern
META_RE: Pattern[str]
META_MORE_RE: Pattern[str]
BEGIN_RE: Pattern[str]
END_RE: Pattern[str]

class MetaExtension(Extension):
md: Any
Expand Down
2 changes: 0 additions & 2 deletions stubs/Markdown/markdown/extensions/nl2br.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any

from markdown.extensions import Extension

BR_RE: str
Expand Down
2 changes: 0 additions & 2 deletions stubs/Markdown/markdown/extensions/sane_lists.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any, Pattern

from markdown.blockprocessors import OListProcessor, UListProcessor
from markdown.extensions import Extension

Expand Down
2 changes: 1 addition & 1 deletion stubs/Markdown/markdown/extensions/smarty.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Pattern
from typing import Any

from markdown.extensions import Extension
from markdown.inlinepatterns import HtmlInlineProcessor
Expand Down
2 changes: 1 addition & 1 deletion stubs/Markdown/markdown/extensions/toc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from markdown.treeprocessors import Treeprocessor

def slugify(value, separator): ...

IDCOUNT_RE: Pattern
IDCOUNT_RE: Pattern[str]

def unique(id, ids): ...
def get_name(el): ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/Markdown/markdown/inlinepatterns.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class Pattern:
@property
def markdown(self): ...
def getCompiledRegExp(self): ...
def handleMatch(self, m: Match) -> Optional[Union[str, Element]]: ...
def handleMatch(self, m: Match[str]) -> Optional[Union[str, Element]]: ...
def type(self): ...
def unescape(self, text): ...

class InlineProcessor(Pattern):
safe_mode: bool = ...
def __init__(self, pattern, md: Optional[Any] = ...) -> None: ...
def handleMatch(self, m: Match, data) -> Union[Tuple[Element, int, int], Tuple[None, None, None]]: ... # type: ignore
def handleMatch(self, m: Match[str], data) -> Union[Tuple[Element, int, int], Tuple[None, None, None]]: ... # type: ignore

class SimpleTextPattern(Pattern): ...
class SimpleTextInlineProcessor(InlineProcessor): ...
Expand Down
2 changes: 0 additions & 2 deletions stubs/Markdown/markdown/pep562.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any

class Version:
def __new__(cls, major, minor, micro, release: str = ..., pre: int = ..., post: int = ..., dev: int = ...): ...

Expand Down
2 changes: 1 addition & 1 deletion stubs/Markdown/markdown/postprocessors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class RawHtmlPostprocessor(Postprocessor):
class AndSubstitutePostprocessor(Postprocessor): ...

class UnescapePostprocessor(Postprocessor):
RE: Pattern
RE: Pattern[str]
def unescape(self, m): ...
6 changes: 3 additions & 3 deletions stubs/Markdown/markdown/preprocessors.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Iterable, List, Pattern
from typing import Any, List, Pattern

from . import util

Expand All @@ -19,5 +19,5 @@ class HtmlBlockPreprocessor(Preprocessor):

class ReferencePreprocessor(Preprocessor):
TITLE: str = ...
RE: Pattern
TITLE_RE: Pattern
RE: Pattern[str]
TITLE_RE: Pattern[str]
2 changes: 0 additions & 2 deletions stubs/Markdown/markdown/serializers.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
from typing import Any

def to_html_string(element): ...
def to_xhtml_string(element): ...
5 changes: 2 additions & 3 deletions stubs/Markdown/markdown/util.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections import namedtuple
from typing import Any, Optional, Pattern

PY37: Any
Expand All @@ -8,10 +7,10 @@ STX: str
ETX: str
INLINE_PLACEHOLDER_PREFIX: Any
INLINE_PLACEHOLDER: Any
INLINE_PLACEHOLDER_RE: Pattern
INLINE_PLACEHOLDER_RE: Pattern[str]
AMP_SUBSTITUTE: Any
HTML_PLACEHOLDER: Any
HTML_PLACEHOLDER_RE: Pattern
HTML_PLACEHOLDER_RE: Pattern[str]
TAG_PLACEHOLDER: Any
INSTALLED_EXTENSIONS: Any
RTL_BIDI_RANGES: Any
Expand Down
Loading