mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 04:25:50 +08:00
[Pygments] Check for missing stubs outside omitted subpackages (#15606)
This commit is contained in:
@@ -3,7 +3,34 @@ pygments.lexer.LexerMeta.__new__
|
||||
pygments.style.StyleMeta.__new__
|
||||
|
||||
# Defined in lexer classes, intended to be used as static method, but doesn't use @staticmethod
|
||||
pygments.lexer.LexerMeta.analyse_text
|
||||
pygments.lexer.Lexer(Meta)?.analyse_text
|
||||
|
||||
# Inheriting from tuple is weird
|
||||
pygments.token._TokenType.__init__
|
||||
|
||||
# Cannot import in stubtest (SystemExit: 2)
|
||||
pygments.__main__
|
||||
|
||||
# Class attributes that are typed in the metaclass instead. See comment in stubs.
|
||||
pygments.lexer.Lexer.name
|
||||
pygments.lexer.Lexer.aliases
|
||||
pygments.lexer.Lexer.filenames
|
||||
pygments.lexer.Lexer.alias_filenames
|
||||
pygments.lexer.Lexer.mimetypes
|
||||
pygments.lexer.Lexer.priority
|
||||
pygments.lexer.Lexer.url
|
||||
pygments.lexer.Lexer.version_added
|
||||
pygments.style.Style.background_color
|
||||
pygments.style.Style.highlight_color
|
||||
pygments.style.Style.line_number_color
|
||||
pygments.style.Style.line_number_background_color
|
||||
pygments.style.Style.line_number_special_color
|
||||
pygments.style.Style.line_number_special_background_color
|
||||
pygments.style.Style.styles
|
||||
pygments.style.Style.name
|
||||
pygments.style.Style.aliases
|
||||
pygments.style.Style.web_style_gallery_exclude
|
||||
|
||||
# Individual lexers and styles submodules are not stubbed at this time.
|
||||
pygments\.lexers\.(?!get_|find_|load_|guess_).*
|
||||
pygments\.styles\.(?!get_).*
|
||||
|
||||
@@ -5,4 +5,3 @@ partial_stub = true
|
||||
|
||||
[tool.stubtest]
|
||||
stubtest_dependencies = ["sphinx"]
|
||||
ignore_missing_stub = true
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import types
|
||||
from _typeshed import Incomplete
|
||||
from typing import Generic, TypeVar, overload
|
||||
from typing import Any, Generic, TypeVar, overload
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["Formatter"]
|
||||
|
||||
class Formatter(Generic[_T]):
|
||||
name: Incomplete
|
||||
aliases: Incomplete
|
||||
@@ -19,5 +22,6 @@ class Formatter(Generic[_T]):
|
||||
def __init__(self: Formatter[bytes], *, encoding: str, outencoding: None = None, **options) -> None: ...
|
||||
@overload
|
||||
def __init__(self: Formatter[bytes], *, encoding: None = None, outencoding: str, **options) -> None: ...
|
||||
def __class_getitem__(cls, name: Any) -> types.GenericAlias: ...
|
||||
def get_style_defs(self, arg: str = ""): ...
|
||||
def format(self, tokensource, outfile): ...
|
||||
|
||||
@@ -3,6 +3,7 @@ from collections.abc import Generator
|
||||
|
||||
from ..formatter import Formatter
|
||||
from .bbcode import BBCodeFormatter as BBCodeFormatter
|
||||
from .groff import GroffFormatter as GroffFormatter
|
||||
from .html import HtmlFormatter as HtmlFormatter
|
||||
from .img import (
|
||||
BmpImageFormatter as BmpImageFormatter,
|
||||
@@ -19,6 +20,31 @@ from .svg import SvgFormatter as SvgFormatter
|
||||
from .terminal import TerminalFormatter as TerminalFormatter
|
||||
from .terminal256 import Terminal256Formatter as Terminal256Formatter, TerminalTrueColorFormatter as TerminalTrueColorFormatter
|
||||
|
||||
__all__ = [
|
||||
"get_formatter_by_name",
|
||||
"get_formatter_for_filename",
|
||||
"get_all_formatters",
|
||||
"load_formatter_from_file",
|
||||
"BBCodeFormatter",
|
||||
"BmpImageFormatter",
|
||||
"GifImageFormatter",
|
||||
"GroffFormatter",
|
||||
"HtmlFormatter",
|
||||
"IRCFormatter",
|
||||
"ImageFormatter",
|
||||
"JpgImageFormatter",
|
||||
"LatexFormatter",
|
||||
"NullFormatter",
|
||||
"PangoMarkupFormatter",
|
||||
"RawTokenFormatter",
|
||||
"RtfFormatter",
|
||||
"SvgFormatter",
|
||||
"Terminal256Formatter",
|
||||
"TerminalFormatter",
|
||||
"TerminalTrueColorFormatter",
|
||||
"TestcaseFormatter",
|
||||
]
|
||||
|
||||
def get_all_formatters() -> Generator[type[Formatter[Incomplete]]]: ...
|
||||
def get_formatter_by_name(_alias, **options): ...
|
||||
def load_formatter_from_file(filename, formattername: str = "CustomFormatter", **options): ...
|
||||
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["BBCodeFormatter"]
|
||||
|
||||
class BBCodeFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
from _typeshed import SupportsWrite
|
||||
from collections.abc import Iterable
|
||||
from typing import TypeVar
|
||||
|
||||
from pygments.formatter import Formatter
|
||||
from pygments.token import _TokenType
|
||||
|
||||
__all__ = ["GroffFormatter"]
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
class GroffFormatter(Formatter[_T]):
|
||||
monospaced: bool
|
||||
linenos: bool
|
||||
wrap: int
|
||||
styles: dict[_TokenType, tuple[str, str]]
|
||||
def __init__(self, **options) -> None: ...
|
||||
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["HtmlFormatter"]
|
||||
|
||||
class HtmlFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["ImageFormatter", "GifImageFormatter", "JpgImageFormatter", "BmpImageFormatter"]
|
||||
|
||||
class PilNotAvailable(ImportError): ...
|
||||
class FontNotFound(Exception): ...
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["IRCFormatter"]
|
||||
|
||||
class IRCFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
|
||||
@@ -6,6 +6,8 @@ from pygments.lexer import Lexer
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["LatexFormatter"]
|
||||
|
||||
class LatexFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["NullFormatter", "RawTokenFormatter", "TestcaseFormatter"]
|
||||
|
||||
class NullFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["PangoMarkupFormatter"]
|
||||
|
||||
class PangoMarkupFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
|
||||
@@ -5,10 +5,14 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["RtfFormatter"]
|
||||
|
||||
class RtfFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
filenames: Incomplete
|
||||
fontface: Incomplete
|
||||
fontsize: Incomplete
|
||||
@staticmethod
|
||||
def hex_to_rtf_color(hex_color: str) -> str: ...
|
||||
def format_unencoded(self, tokensource, outfile) -> None: ...
|
||||
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["SvgFormatter"]
|
||||
|
||||
class SvgFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["TerminalFormatter"]
|
||||
|
||||
class TerminalFormatter(Formatter[_T]):
|
||||
name: str
|
||||
aliases: Incomplete
|
||||
|
||||
@@ -5,6 +5,8 @@ from pygments.formatter import Formatter
|
||||
|
||||
_T = TypeVar("_T", str, bytes)
|
||||
|
||||
__all__ = ["Terminal256Formatter", "TerminalTrueColorFormatter"]
|
||||
|
||||
class EscapeSequence:
|
||||
fg: Incomplete
|
||||
bg: Incomplete
|
||||
|
||||
@@ -1,22 +1,41 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Iterable, Iterator, Sequence
|
||||
from re import RegexFlag
|
||||
from typing import ClassVar
|
||||
from re import Pattern, RegexFlag
|
||||
from typing import ClassVar, Final
|
||||
|
||||
from pygments.token import _TokenType
|
||||
from pygments.util import Future
|
||||
|
||||
__all__ = [
|
||||
"Lexer",
|
||||
"RegexLexer",
|
||||
"ExtendedRegexLexer",
|
||||
"DelegatingLexer",
|
||||
"LexerContext",
|
||||
"include",
|
||||
"inherit",
|
||||
"bygroups",
|
||||
"using",
|
||||
"this",
|
||||
"default",
|
||||
"words",
|
||||
"line_re",
|
||||
]
|
||||
|
||||
line_re: Final[Pattern[str]]
|
||||
|
||||
class LexerMeta(type):
|
||||
def __new__(cls, name, bases, d): ...
|
||||
def analyse_text(self, text: str) -> float: ... # actually defined in class Lexer
|
||||
# ClassVars of Lexer, but same situation as with StyleMeta and Style
|
||||
name: str
|
||||
name: str # Set to None in Lexer, but always overridden with a non-None value in subclasses.
|
||||
aliases: Sequence[str] # not intended mutable
|
||||
filenames: Sequence[str]
|
||||
alias_filenames: Sequence[str]
|
||||
mimetypes: Sequence[str]
|
||||
priority: float
|
||||
url: str | None
|
||||
url: str # Set to None in Lexer, but always overridden with a non-None value in subclasses.
|
||||
version_added: str # Set to None in Lexer, but always overridden with a non-None value in subclasses.
|
||||
|
||||
class Lexer(metaclass=LexerMeta):
|
||||
options: Incomplete
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
__all__ = ["get_filetype_from_buffer"]
|
||||
|
||||
def get_filetype_from_buffer(buf, max_lines: int = 5): ...
|
||||
|
||||
@@ -7,6 +7,7 @@ FILTERDOC: str
|
||||
|
||||
class PygmentsDoc(Directive):
|
||||
filenames: set[str]
|
||||
def document_lexers_overview(self) -> str: ...
|
||||
def document_lexers(self) -> str: ...
|
||||
def document_formatters(self) -> str: ...
|
||||
def document_filters(self) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user