Skip to content

Commit f7980c9

Browse files
[Pygments] Accept byte input when lexing and highlighting (#16754)
1 parent dbca2d7 commit f7980c9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎stubs/Pygments/pygments/__init__.pyi‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ __version__: Final[str]
1212
__docformat__: Final = "restructuredtext"
1313
__all__ = ["lex", "format", "highlight"]
1414

15-
def lex(code: str, lexer: Lexer) -> Iterator[tuple[_TokenType, str]]: ...
15+
def lex(code: str | bytes | bytearray, lexer: Lexer) -> Iterator[tuple[_TokenType, str]]: ...
1616

1717
@overload
1818
def format(tokens: Iterable[tuple[_TokenType, str]], formatter: Formatter[_T], outfile: SupportsWrite[_T]) -> None: ...
1919
@overload
2020
def format(tokens: Iterable[tuple[_TokenType, str]], formatter: Formatter[_T], outfile: None = None) -> _T: ...
2121

2222
@overload
23-
def highlight(code: str, lexer: Lexer, formatter: Formatter[_T], outfile: SupportsWrite[_T]) -> None: ...
23+
def highlight(code: str | bytes | bytearray, lexer: Lexer, formatter: Formatter[_T], outfile: SupportsWrite[_T]) -> None: ...
2424
@overload
25-
def highlight(code: str, lexer: Lexer, formatter: Formatter[_T], outfile: None = None) -> _T: ...
25+
def highlight(code: str | bytes | bytearray, lexer: Lexer, formatter: Formatter[_T], outfile: None = None) -> _T: ...

‎stubs/Pygments/pygments/lexer.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Lexer(metaclass=LexerMeta):
4747
def add_filter(self, filter_, **options) -> None: ...
4848
@staticmethod # @staticmethod added by special handling in metaclass
4949
def analyse_text(text: str) -> float: ...
50-
def get_tokens(self, text: str, unfiltered: bool = False) -> Iterator[tuple[_TokenType, str]]: ...
50+
def get_tokens(self, text: str | bytes | bytearray, unfiltered: bool = False) -> Iterator[tuple[_TokenType, str]]: ...
5151
def get_tokens_unprocessed(self, text: str) -> Iterator[tuple[int, _TokenType, str]]: ...
5252

5353
class DelegatingLexer(Lexer):

0 commit comments

Comments
 (0)