-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Pygments: Add return types for format/highlight. #6819
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
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
65d4d04
Add return types for format/highlight.
Dreamsorcerer 243abca
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ad64fc0
Update __init__.pyi
Dreamsorcerer 34d4f1e
Update __init__.pyi
Dreamsorcerer 2febfaf
Make formatter generic
Dreamsorcerer 3d86e08
Update __init__.pyi
Dreamsorcerer a817551
Update formatter.pyi
Dreamsorcerer 316a5e1
Update __init__.pyi
Dreamsorcerer 0b0efbe
Update plugin.pyi
Dreamsorcerer c17d032
Update __init__.pyi
Dreamsorcerer 8a8a6d9
Update bbcode.pyi
Dreamsorcerer 617943e
Update html.pyi
Dreamsorcerer d992336
Update img.pyi
Dreamsorcerer ce3bcc0
Update irc.pyi
Dreamsorcerer 66dae1d
Update latex.pyi
Dreamsorcerer 6d98106
Update other.pyi
Dreamsorcerer 780d5e9
Update pangomarkup.pyi
Dreamsorcerer bd1e9cb
Update rtf.pyi
Dreamsorcerer b58b7fe
Update svg.pyi
Dreamsorcerer 972a671
Update terminal.pyi
Dreamsorcerer 6e28321
Update terminal256.pyi
Dreamsorcerer 772ea1f
Update bbcode.pyi
Dreamsorcerer dd2c3ff
Update stubs/Pygments/pygments/formatter.pyi
Dreamsorcerer 3ac61af
Update __init__.pyi
Dreamsorcerer 2c617b8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0630cc4
Update __init__.pyi
Dreamsorcerer 25c992e
Update __init__.pyi
Dreamsorcerer 0a2c798
Update stubs/Pygments/pygments/__init__.pyi
Dreamsorcerer 82eeb4e
Update stubs/Pygments/pygments/__init__.pyi
Akuli d627628
Merge branch 'master' into patch-19
Dreamsorcerer 785104c
Update __init__.pyi
Dreamsorcerer 3292cd8
Update __init__.pyi
Dreamsorcerer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
from typing import Any | ||
from io import FileIO | ||
from typing import Any, TypeVar, overload | ||
|
||
from pygments.formatters import Formatter | ||
|
||
_T = TypeVar("_T", str, bytes) | ||
|
||
def lex(code, lexer): ... | ||
def format(tokens, formatter, outfile: Any | None = ...): ... | ||
def highlight(code, lexer, formatter, outfile: Any | None = ...): ... | ||
@overload | ||
def format(tokens, formatter: Formatter[Any], outfile: FileIO) -> None: ... | ||
@overload | ||
def format(tokens, formatter: Formatter[_T], outfile: None = ...) -> _T: ... | ||
@overload | ||
def highlight(code, lexer, formatter, outfile: FileIO) -> None: ... | ||
@overload | ||
def highlight(code, lexer, formatter, outfile: None = ...) -> str: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
from typing import Any | ||
from typing import Any, TypeVar | ||
|
||
from pygments.formatter import Formatter | ||
|
||
class BBCodeFormatter(Formatter): | ||
_T = TypeVar("_T", str, bytes) | ||
|
||
class BBCodeFormatter(Formatter[_T]): | ||
name: str | ||
aliases: Any | ||
filenames: Any | ||
styles: Any | ||
def __init__(self, **options) -> None: ... | ||
def format_unencoded(self, tokensource, outfile) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
from typing import Any | ||
from typing import Any, TypeVar | ||
|
||
from pygments.formatter import Formatter | ||
|
||
class IRCFormatter(Formatter): | ||
_T = TypeVar("_T", str, bytes) | ||
|
||
class IRCFormatter(Formatter[_T]): | ||
name: str | ||
aliases: Any | ||
filenames: Any | ||
darkbg: Any | ||
colorscheme: Any | ||
linenos: Any | ||
def __init__(self, **options) -> None: ... | ||
def format_unencoded(self, tokensource, outfile) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
from typing import Any | ||
from typing import Any, TypeVar | ||
|
||
from pygments.formatter import Formatter | ||
|
||
class NullFormatter(Formatter): | ||
_T = TypeVar("_T", str, bytes) | ||
|
||
class NullFormatter(Formatter[_T]): | ||
name: str | ||
aliases: Any | ||
filenames: Any | ||
def format(self, tokensource, outfile) -> None: ... | ||
|
||
class RawTokenFormatter(Formatter): | ||
class RawTokenFormatter(Formatter[_T]): | ||
name: str | ||
aliases: Any | ||
filenames: Any | ||
unicodeoutput: bool | ||
encoding: str | ||
compress: Any | ||
error_color: Any | ||
def __init__(self, **options) -> None: ... | ||
def format(self, tokensource, outfile) -> None: ... | ||
|
||
class TestcaseFormatter(Formatter): | ||
class TestcaseFormatter(Formatter[_T]): | ||
name: str | ||
aliases: Any | ||
def __init__(self, **options) -> None: ... | ||
def format(self, tokensource, outfile) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
from typing import Any | ||
from typing import Any, TypeVar | ||
|
||
from pygments.formatter import Formatter | ||
|
||
class PangoMarkupFormatter(Formatter): | ||
_T = TypeVar("_T", str, bytes) | ||
|
||
class PangoMarkupFormatter(Formatter[_T]): | ||
name: str | ||
aliases: Any | ||
filenames: Any | ||
styles: Any | ||
def __init__(self, **options) -> None: ... | ||
def format_unencoded(self, tokensource, outfile) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
from typing import Any | ||
from typing import Any, TypeVar | ||
|
||
from pygments.formatter import Formatter | ||
|
||
class RtfFormatter(Formatter): | ||
_T = TypeVar("_T", str, bytes) | ||
|
||
class RtfFormatter(Formatter[_T]): | ||
name: str | ||
aliases: Any | ||
filenames: Any | ||
fontface: Any | ||
fontsize: Any | ||
def __init__(self, **options) -> None: ... | ||
def format_unencoded(self, tokensource, outfile) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
from typing import Any | ||
from typing import Any, TypeVar | ||
|
||
from pygments.formatter import Formatter | ||
|
||
class TerminalFormatter(Formatter): | ||
_T = TypeVar("_T", str, bytes) | ||
|
||
class TerminalFormatter(Formatter[_T]): | ||
name: str | ||
aliases: Any | ||
filenames: Any | ||
darkbg: Any | ||
colorscheme: Any | ||
linenos: Any | ||
def __init__(self, **options) -> None: ... | ||
def format(self, tokensource, outfile): ... | ||
def format_unencoded(self, tokensource, outfile) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.