[Pygments] Cleanup metaclass workarounds for mypy<1.1 (#15607)

This commit is contained in:
Brian Schubert
2026-04-05 17:45:24 +02:00
committed by GitHub
parent c6b7c0b144
commit e8d2bc6708
5 changed files with 39 additions and 50 deletions
+2 -19
View File
@@ -2,34 +2,17 @@
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.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.
# Class attributes that are set to None in the base class, but are
# always overridden with a non-None value in subclasses.
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_).*
@@ -0,0 +1,10 @@
from typing_extensions import assert_type
from pygments.style import Style, _StyleDict
from pygments.token import _TokenType
def test_style_class_iterable(style_class: type[Style]) -> None:
for t, d in style_class:
assert_type(t, _TokenType)
assert_type(d, _StyleDict)