Skip to content

Commit b838d1b

Browse files
committed
Upgrade pygments to 2.18.0
1 parent 92940a9 commit b838d1b

37 files changed

+487
-292
lines changed

news/pygments.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade pygments to 2.18.0

src/pip/_vendor/pygments/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
.. _Pygments master branch:
2222
https://github.com/pygments/pygments/archive/master.zip#egg=Pygments-dev
2323
24-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
24+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
2525
:license: BSD, see LICENSE for details.
2626
"""
2727
from io import StringIO, BytesIO
2828

29-
__version__ = '2.17.2'
29+
__version__ = '2.18.0'
3030
__docformat__ = 'restructuredtext'
3131

3232
__all__ = ['lex', 'format', 'highlight']

src/pip/_vendor/pygments/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Main entry point for ``python -m pygments``.
66
7-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
7+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
88
:license: BSD, see LICENSE for details.
99
"""
1010

src/pip/_vendor/pygments/cmdline.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Command line interface.
66
7-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
7+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
88
:license: BSD, see LICENSE for details.
99
"""
1010

@@ -68,19 +68,19 @@ def _print_help(what, name):
6868
try:
6969
if what == 'lexer':
7070
cls = get_lexer_by_name(name)
71-
print("Help on the %s lexer:" % cls.name)
71+
print(f"Help on the {cls.name} lexer:")
7272
print(dedent(cls.__doc__))
7373
elif what == 'formatter':
7474
cls = find_formatter_class(name)
75-
print("Help on the %s formatter:" % cls.name)
75+
print(f"Help on the {cls.name} formatter:")
7676
print(dedent(cls.__doc__))
7777
elif what == 'filter':
7878
cls = find_filter_class(name)
79-
print("Help on the %s filter:" % name)
79+
print(f"Help on the {name} filter:")
8080
print(dedent(cls.__doc__))
8181
return 0
8282
except (AttributeError, ValueError):
83-
print("%s not found!" % what, file=sys.stderr)
83+
print(f"{what} not found!", file=sys.stderr)
8484
return 1
8585

8686

@@ -97,7 +97,7 @@ def _print_list(what):
9797
info.append(tup)
9898
info.sort()
9999
for i in info:
100-
print(('* %s\n %s %s') % i)
100+
print(('* {}\n {} {}').format(*i))
101101

102102
elif what == 'formatter':
103103
print()
@@ -112,7 +112,7 @@ def _print_list(what):
112112
info.append(tup)
113113
info.sort()
114114
for i in info:
115-
print(('* %s\n %s %s') % i)
115+
print(('* {}\n {} {}').format(*i))
116116

117117
elif what == 'filter':
118118
print()
@@ -122,7 +122,7 @@ def _print_list(what):
122122
for name in get_all_filters():
123123
cls = find_filter_class(name)
124124
print("* " + name + ':')
125-
print(" %s" % docstring_headline(cls))
125+
print(f" {docstring_headline(cls)}")
126126

127127
elif what == 'style':
128128
print()
@@ -132,7 +132,7 @@ def _print_list(what):
132132
for name in get_all_styles():
133133
cls = get_style_by_name(name)
134134
print("* " + name + ':')
135-
print(" %s" % docstring_headline(cls))
135+
print(f" {docstring_headline(cls)}")
136136

137137

138138
def _print_list_as_json(requested_items):
@@ -185,8 +185,8 @@ def main_inner(parser, argns):
185185
return 0
186186

187187
if argns.V:
188-
print('Pygments version %s, (c) 2006-2023 by Georg Brandl, Matthäus '
189-
'Chajdas and contributors.' % __version__)
188+
print(f'Pygments version {__version__}, (c) 2006-2024 by Georg Brandl, Matthäus '
189+
'Chajdas and contributors.')
190190
return 0
191191

192192
def is_only_option(opt):
@@ -659,7 +659,7 @@ def main(args=sys.argv):
659659
msg = info[-1].strip()
660660
if len(info) >= 3:
661661
# extract relevant file and position info
662-
msg += '\n (f%s)' % info[-2].split('\n')[0].strip()[1:]
662+
msg += '\n (f{})'.format(info[-2].split('\n')[0].strip()[1:])
663663
print(file=sys.stderr)
664664
print('*** Error while highlighting:', file=sys.stderr)
665665
print(msg, file=sys.stderr)

src/pip/_vendor/pygments/console.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Format colored console output.
66
7-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
7+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
88
:license: BSD, see LICENSE for details.
99
"""
1010

@@ -27,12 +27,12 @@
2727
"brightmagenta", "brightcyan", "white"]
2828

2929
x = 30
30-
for d, l in zip(dark_colors, light_colors):
31-
codes[d] = esc + "%im" % x
32-
codes[l] = esc + "%im" % (60 + x)
30+
for dark, light in zip(dark_colors, light_colors):
31+
codes[dark] = esc + "%im" % x
32+
codes[light] = esc + "%im" % (60 + x)
3333
x += 1
3434

35-
del d, l, x
35+
del dark, light, x
3636

3737
codes["white"] = codes["bold"]
3838

src/pip/_vendor/pygments/filter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Module that implements the default filter.
66
7-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
7+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
88
:license: BSD, see LICENSE for details.
99
"""
1010

@@ -62,8 +62,7 @@ class FunctionFilter(Filter):
6262

6363
def __init__(self, **options):
6464
if not hasattr(self, 'function'):
65-
raise TypeError('%r used without bound function' %
66-
self.__class__.__name__)
65+
raise TypeError(f'{self.__class__.__name__!r} used without bound function')
6766
Filter.__init__(self, **options)
6867

6968
def filter(self, lexer, stream):

src/pip/_vendor/pygments/filters/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Module containing filter lookup functions and default
66
filters.
77
8-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
8+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
99
:license: BSD, see LICENSE for details.
1010
"""
1111

@@ -39,7 +39,7 @@ def get_filter_by_name(filtername, **options):
3939
if cls:
4040
return cls(**options)
4141
else:
42-
raise ClassNotFound('filter %r not found' % filtername)
42+
raise ClassNotFound(f'filter {filtername!r} not found')
4343

4444

4545
def get_all_filters():
@@ -79,9 +79,9 @@ def __init__(self, **options):
7979
Filter.__init__(self, **options)
8080
tags = get_list_opt(options, 'codetags',
8181
['XXX', 'TODO', 'FIXME', 'BUG', 'NOTE'])
82-
self.tag_re = re.compile(r'\b(%s)\b' % '|'.join([
82+
self.tag_re = re.compile(r'\b({})\b'.format('|'.join([
8383
re.escape(tag) for tag in tags if tag
84-
]))
84+
])))
8585

8686
def filter(self, lexer, stream):
8787
regex = self.tag_re

src/pip/_vendor/pygments/formatter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Base formatter class.
66
7-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
7+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
88
:license: BSD, see LICENSE for details.
99
"""
1010

@@ -122,3 +122,8 @@ def format(self, tokensource, outfile):
122122
# wrap the outfile in a StreamWriter
123123
outfile = codecs.lookup(self.encoding)[3](outfile)
124124
return self.format_unencoded(tokensource, outfile)
125+
126+
# Allow writing Formatter[str] or Formatter[bytes]. That's equivalent to
127+
# Formatter. This helps when using third-party type stubs from typeshed.
128+
def __class_getitem__(cls, name):
129+
return cls

src/pip/_vendor/pygments/formatters/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Pygments formatters.
66
7-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
7+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
88
:license: BSD, see LICENSE for details.
99
"""
1010

@@ -77,7 +77,7 @@ def get_formatter_by_name(_alias, **options):
7777
"""
7878
cls = find_formatter_class(_alias)
7979
if cls is None:
80-
raise ClassNotFound("no formatter found for name %r" % _alias)
80+
raise ClassNotFound(f"no formatter found for name {_alias!r}")
8181
return cls(**options)
8282

8383

@@ -103,17 +103,16 @@ def load_formatter_from_file(filename, formattername="CustomFormatter", **option
103103
exec(f.read(), custom_namespace)
104104
# Retrieve the class `formattername` from that namespace
105105
if formattername not in custom_namespace:
106-
raise ClassNotFound('no valid %s class found in %s' %
107-
(formattername, filename))
106+
raise ClassNotFound(f'no valid {formattername} class found in {filename}')
108107
formatter_class = custom_namespace[formattername]
109108
# And finally instantiate it with the options
110109
return formatter_class(**options)
111110
except OSError as err:
112-
raise ClassNotFound('cannot read %s: %s' % (filename, err))
111+
raise ClassNotFound(f'cannot read {filename}: {err}')
113112
except ClassNotFound:
114113
raise
115114
except Exception as err:
116-
raise ClassNotFound('error when loading custom formatter: %s' % err)
115+
raise ClassNotFound(f'error when loading custom formatter: {err}')
117116

118117

119118
def get_formatter_for_filename(fn, **options):
@@ -135,7 +134,7 @@ def get_formatter_for_filename(fn, **options):
135134
for filename in cls.filenames:
136135
if _fn_matches(fn, filename):
137136
return cls(**options)
138-
raise ClassNotFound("no formatter found for file name %r" % fn)
137+
raise ClassNotFound(f"no formatter found for file name {fn!r}")
139138

140139

141140
class _automodule(types.ModuleType):

src/pip/_vendor/pygments/formatters/bbcode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
BBcode formatter.
66
7-
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
7+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
88
:license: BSD, see LICENSE for details.
99
"""
1010

@@ -60,7 +60,7 @@ def _make_styles(self):
6060
for ttype, ndef in self.style:
6161
start = end = ''
6262
if ndef['color']:
63-
start += '[color=#%s]' % ndef['color']
63+
start += '[color=#{}]'.format(ndef['color'])
6464
end = '[/color]' + end
6565
if ndef['bold']:
6666
start += '[b]'

0 commit comments

Comments
 (0)