summaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/util.py
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2024-05-20 07:58:40 +0300
committerrobot-piglet <[email protected]>2024-05-20 08:05:00 +0300
commitbcd5bcc390793791d293d386b2ebefbe683fb4e1 (patch)
treec93e3b8c847237e7e7626f4a07f1b657bb34f04d /contrib/python/Pygments/py3/pygments/util.py
parent1a9f1508fe9c8c5927ffebf33197a6108e70501d (diff)
Intermediate changes
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/util.py')
-rw-r--r--contrib/python/Pygments/py3/pygments/util.py32
1 files changed, 13 insertions, 19 deletions
diff --git a/contrib/python/Pygments/py3/pygments/util.py b/contrib/python/Pygments/py3/pygments/util.py
index 941fdb9ec7a..83cf1049253 100644
--- a/contrib/python/Pygments/py3/pygments/util.py
+++ b/contrib/python/Pygments/py3/pygments/util.py
@@ -4,7 +4,7 @@
Utility functions.
- :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -46,8 +46,7 @@ def get_choice_opt(options, optname, allowed, default=None, normcase=False):
if normcase:
string = string.lower()
if string not in allowed:
- raise OptionError('Value for option %s must be one of %s' %
- (optname, ', '.join(map(str, allowed))))
+ raise OptionError('Value for option {} must be one of {}'.format(optname, ', '.join(map(str, allowed))))
return string
@@ -69,17 +68,15 @@ def get_bool_opt(options, optname, default=None):
elif isinstance(string, int):
return bool(string)
elif not isinstance(string, str):
- raise OptionError('Invalid type %r for option %s; use '
- '1/0, yes/no, true/false, on/off' % (
- string, optname))
+ raise OptionError(f'Invalid type {string!r} for option {optname}; use '
+ '1/0, yes/no, true/false, on/off')
elif string.lower() in ('1', 'yes', 'true', 'on'):
return True
elif string.lower() in ('0', 'no', 'false', 'off'):
return False
else:
- raise OptionError('Invalid value %r for option %s; use '
- '1/0, yes/no, true/false, on/off' % (
- string, optname))
+ raise OptionError(f'Invalid value {string!r} for option {optname}; use '
+ '1/0, yes/no, true/false, on/off')
def get_int_opt(options, optname, default=None):
@@ -88,13 +85,11 @@ def get_int_opt(options, optname, default=None):
try:
return int(string)
except TypeError:
- raise OptionError('Invalid type %r for option %s; you '
- 'must give an integer value' % (
- string, optname))
+ raise OptionError(f'Invalid type {string!r} for option {optname}; you '
+ 'must give an integer value')
except ValueError:
- raise OptionError('Invalid value %r for option %s; you '
- 'must give an integer value' % (
- string, optname))
+ raise OptionError(f'Invalid value {string!r} for option {optname}; you '
+ 'must give an integer value')
def get_list_opt(options, optname, default=None):
"""
@@ -108,9 +103,8 @@ def get_list_opt(options, optname, default=None):
elif isinstance(val, (list, tuple)):
return list(val)
else:
- raise OptionError('Invalid type %r for option %s; you '
- 'must give a list value' % (
- val, optname))
+ raise OptionError(f'Invalid type {val!r} for option {optname}; you '
+ 'must give a list value')
def docstring_headline(obj):
@@ -181,7 +175,7 @@ def shebang_matches(text, regex):
if x and not x.startswith('-')][-1]
except IndexError:
return False
- regex = re.compile(r'^%s(\.(exe|cmd|bat|bin))?$' % regex, re.IGNORECASE)
+ regex = re.compile(rf'^{regex}(\.(exe|cmd|bat|bin))?$', re.IGNORECASE)
if regex.search(found) is not None:
return True
return False