Skip to content

Commit df5dcd8

Browse files
authored
Merge branch 'main' into operator.add_sub
2 parents b17f0fc + 4edae94 commit df5dcd8

27 files changed

+146
-13
lines changed

stdlib/_operator.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from _typeshed import SupportsAdd, SupportsGetItem, SupportsMul, SupportsRAdd, SupportsRMul, SupportsRSub, SupportsSub
2+
from _typeshed import SupportsAdd, SupportsGetItem, SupportsMod, SupportsMul, SupportsRAdd, SupportsRMod, SupportsRMul, SupportsRSub, SupportsSub
33
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
44
from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller
55
from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload, type_check_only
@@ -69,7 +69,10 @@ def index(a: SupportsIndex, /) -> int: ...
6969
def inv(a: _SupportsInversion[_T_co], /) -> _T_co: ...
7070
def invert(a: _SupportsInversion[_T_co], /) -> _T_co: ...
7171
def lshift(a, b, /): ...
72-
def mod(a, b, /): ...
72+
@overload
73+
def mod(a: SupportsMod[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ...
74+
@overload
75+
def mod(a: _T_contra, b: SupportsRMod[_T_contra, _T_co], /) -> _T_co: ...
7376
@overload
7477
def mul(a: SupportsMul[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ...
7578
@overload

stdlib/_typeshed/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ class SupportsMul(Protocol[_T_contra, _T_co]):
126126
class SupportsRMul(Protocol[_T_contra, _T_co]):
127127
def __rmul__(self, x: _T_contra, /) -> _T_co: ...
128128

129+
class SupportsMod(Protocol[_T_contra, _T_co]):
130+
def __mod__(self, other: _T_contra, /) -> _T_co: ...
131+
132+
class SupportsRMod(Protocol[_T_contra, _T_co]):
133+
def __rmod__(self, other: _T_contra, /) -> _T_co: ...
134+
129135
class SupportsDivMod(Protocol[_T_contra, _T_co]):
130136
def __divmod__(self, other: _T_contra, /) -> _T_co: ...
131137

stubs/Pygments/@tests/stubtest_allowlist.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,34 @@ pygments.lexer.LexerMeta.__new__
33
pygments.style.StyleMeta.__new__
44

55
# Defined in lexer classes, intended to be used as static method, but doesn't use @staticmethod
6-
pygments.lexer.LexerMeta.analyse_text
6+
pygments.lexer.Lexer(Meta)?.analyse_text
77

88
# Inheriting from tuple is weird
99
pygments.token._TokenType.__init__
10+
11+
# Cannot import in stubtest (SystemExit: 2)
12+
pygments.__main__
13+
14+
# Class attributes that are typed in the metaclass instead. See comment in stubs.
15+
pygments.lexer.Lexer.name
16+
pygments.lexer.Lexer.aliases
17+
pygments.lexer.Lexer.filenames
18+
pygments.lexer.Lexer.alias_filenames
19+
pygments.lexer.Lexer.mimetypes
20+
pygments.lexer.Lexer.priority
21+
pygments.lexer.Lexer.url
22+
pygments.lexer.Lexer.version_added
23+
pygments.style.Style.background_color
24+
pygments.style.Style.highlight_color
25+
pygments.style.Style.line_number_color
26+
pygments.style.Style.line_number_background_color
27+
pygments.style.Style.line_number_special_color
28+
pygments.style.Style.line_number_special_background_color
29+
pygments.style.Style.styles
30+
pygments.style.Style.name
31+
pygments.style.Style.aliases
32+
pygments.style.Style.web_style_gallery_exclude
33+
34+
# Individual lexers and styles submodules are not stubbed at this time.
35+
pygments\.lexers\.(?!get_|find_|load_|guess_).*
36+
pygments\.styles\.(?!get_).*

stubs/Pygments/METADATA.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
version = "2.19.*"
1+
version = "2.20.*"
22
upstream_repository = "https://github.com/pygments/pygments"
33
dependencies = ["types-docutils"]
44
partial_stub = true
55

66
[tool.stubtest]
77
stubtest_dependencies = ["sphinx"]
8-
ignore_missing_stub = true

stubs/Pygments/pygments/formatter.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import types
12
from _typeshed import Incomplete
2-
from typing import Generic, TypeVar, overload
3+
from typing import Any, Generic, TypeVar, overload
34

45
_T = TypeVar("_T", str, bytes)
56

7+
__all__ = ["Formatter"]
8+
69
class Formatter(Generic[_T]):
710
name: Incomplete
811
aliases: Incomplete
@@ -19,5 +22,6 @@ class Formatter(Generic[_T]):
1922
def __init__(self: Formatter[bytes], *, encoding: str, outencoding: None = None, **options) -> None: ...
2023
@overload
2124
def __init__(self: Formatter[bytes], *, encoding: None = None, outencoding: str, **options) -> None: ...
25+
def __class_getitem__(cls, name: Any) -> types.GenericAlias: ...
2226
def get_style_defs(self, arg: str = ""): ...
2327
def format(self, tokensource, outfile): ...

stubs/Pygments/pygments/formatters/__init__.pyi

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from collections.abc import Generator
33

44
from ..formatter import Formatter
55
from .bbcode import BBCodeFormatter as BBCodeFormatter
6+
from .groff import GroffFormatter as GroffFormatter
67
from .html import HtmlFormatter as HtmlFormatter
78
from .img import (
89
BmpImageFormatter as BmpImageFormatter,
@@ -19,6 +20,31 @@ from .svg import SvgFormatter as SvgFormatter
1920
from .terminal import TerminalFormatter as TerminalFormatter
2021
from .terminal256 import Terminal256Formatter as Terminal256Formatter, TerminalTrueColorFormatter as TerminalTrueColorFormatter
2122

23+
__all__ = [
24+
"get_formatter_by_name",
25+
"get_formatter_for_filename",
26+
"get_all_formatters",
27+
"load_formatter_from_file",
28+
"BBCodeFormatter",
29+
"BmpImageFormatter",
30+
"GifImageFormatter",
31+
"GroffFormatter",
32+
"HtmlFormatter",
33+
"IRCFormatter",
34+
"ImageFormatter",
35+
"JpgImageFormatter",
36+
"LatexFormatter",
37+
"NullFormatter",
38+
"PangoMarkupFormatter",
39+
"RawTokenFormatter",
40+
"RtfFormatter",
41+
"SvgFormatter",
42+
"Terminal256Formatter",
43+
"TerminalFormatter",
44+
"TerminalTrueColorFormatter",
45+
"TestcaseFormatter",
46+
]
47+
2248
def get_all_formatters() -> Generator[type[Formatter[Incomplete]]]: ...
2349
def get_formatter_by_name(_alias, **options): ...
2450
def load_formatter_from_file(filename, formattername: str = "CustomFormatter", **options): ...

stubs/Pygments/pygments/formatters/bbcode.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
55

66
_T = TypeVar("_T", str, bytes)
77

8+
__all__ = ["BBCodeFormatter"]
9+
810
class BBCodeFormatter(Formatter[_T]):
911
name: str
1012
aliases: Incomplete
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from _typeshed import SupportsWrite
2+
from collections.abc import Iterable
3+
from typing import TypeVar
4+
5+
from pygments.formatter import Formatter
6+
from pygments.token import _TokenType
7+
8+
__all__ = ["GroffFormatter"]
9+
10+
_T = TypeVar("_T", str, bytes)
11+
12+
class GroffFormatter(Formatter[_T]):
13+
monospaced: bool
14+
linenos: bool
15+
wrap: int
16+
styles: dict[_TokenType, tuple[str, str]]
17+
def __init__(self, **options) -> None: ...
18+
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...

stubs/Pygments/pygments/formatters/html.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
55

66
_T = TypeVar("_T", str, bytes)
77

8+
__all__ = ["HtmlFormatter"]
9+
810
class HtmlFormatter(Formatter[_T]):
911
name: str
1012
aliases: Incomplete

stubs/Pygments/pygments/formatters/img.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
55

66
_T = TypeVar("_T", str, bytes)
77

8+
__all__ = ["ImageFormatter", "GifImageFormatter", "JpgImageFormatter", "BmpImageFormatter"]
9+
810
class PilNotAvailable(ImportError): ...
911
class FontNotFound(Exception): ...
1012

0 commit comments

Comments
 (0)