mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 01:08:10 +02:00
run pyupgrade to upgrade the codebase to python3.6
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
@@ -105,7 +104,7 @@ def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
|
||||
t(f' ans[{option.name!r}] = {func.__name__}(val)')
|
||||
tc_imports.add((func.__module__, func.__name__))
|
||||
cnum = int(option.name[5:])
|
||||
color_table[cnum] = '0x{:06x}'.format(func(option.defval_as_string).__int__())
|
||||
color_table[cnum] = f'0x{func(option.defval_as_string).__int__():06x}'
|
||||
continue
|
||||
else:
|
||||
func, typ = option_type_data(option)
|
||||
@@ -331,7 +330,7 @@ def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
|
||||
t(' return True')
|
||||
t(' return False')
|
||||
|
||||
preamble = ['# generated by gen-config.py DO NOT edit', '# vim:fileencoding=utf-8', '']
|
||||
preamble = ['# generated by gen-config.py DO NOT edit', '']
|
||||
a = preamble.append
|
||||
|
||||
def output_imports(imports: Set, add_module_imports: bool = True) -> None:
|
||||
@@ -368,7 +367,7 @@ def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
|
||||
a(' ' + pprint.pformat(tuple(sorted(option_names, key=natural_keys)))[1:] + ' # }}''}')
|
||||
class_def = '\n'.join(preamble + ['', ''] + class_lines)
|
||||
|
||||
preamble = ['# generated by gen-config.py DO NOT edit', '# vim:fileencoding=utf-8', '']
|
||||
preamble = ['# generated by gen-config.py DO NOT edit', '']
|
||||
a = preamble.append
|
||||
output_imports(tc_imports, False)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import builtins
|
||||
@@ -35,7 +34,7 @@ def expand_opt_references(conf_name: str, text: str) -> str:
|
||||
ref = m.group(1)
|
||||
if '<' not in ref and '.' not in ref:
|
||||
full_ref = conf_name + ref
|
||||
return ':opt:`{} <{}>`'.format(ref, full_ref)
|
||||
return f':opt:`{ref} <{full_ref}>`'
|
||||
return str(m.group())
|
||||
|
||||
return re.sub(r':opt:`(.+?)`', expand, text)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os
|
||||
@@ -130,7 +129,7 @@ def parse_line(
|
||||
return
|
||||
m = key_pat.match(line)
|
||||
if m is None:
|
||||
log_error('Ignoring invalid config line: {}'.format(line))
|
||||
log_error(f'Ignoring invalid config line: {line}')
|
||||
return
|
||||
key, val = m.groups()
|
||||
if key == 'include':
|
||||
@@ -152,7 +151,7 @@ def parse_line(
|
||||
)
|
||||
return
|
||||
if not parse_conf_item(key, val, ans):
|
||||
log_error('Ignoring unknown config key: {}'.format(key))
|
||||
log_error(f'Ignoring unknown config key: {key}')
|
||||
|
||||
|
||||
def _parse(
|
||||
@@ -199,8 +198,7 @@ def resolve_config(SYSTEM_CONF: str, defconf: str, config_files_on_cmd_line: Seq
|
||||
if config_files_on_cmd_line:
|
||||
if 'NONE' not in config_files_on_cmd_line:
|
||||
yield SYSTEM_CONF
|
||||
for cf in config_files_on_cmd_line:
|
||||
yield cf
|
||||
yield from config_files_on_cmd_line
|
||||
else:
|
||||
yield SYSTEM_CONF
|
||||
yield defconf
|
||||
@@ -240,7 +238,7 @@ def key_func() -> Tuple[Callable[..., Callable], Dict[str, Callable]]:
|
||||
for name in names:
|
||||
if ans.setdefault(name, f) is not f:
|
||||
raise ValueError(
|
||||
'the args_func {} is being redefined'.format(name)
|
||||
f'the args_func {name} is being redefined'
|
||||
)
|
||||
return f
|
||||
|
||||
@@ -277,7 +275,7 @@ def parse_kittens_func_args(action: str, args_funcs: Dict[str, Callable]) -> Key
|
||||
try:
|
||||
func, args = parser(func, rest)
|
||||
except Exception:
|
||||
raise ValueError('Unknown key action: {}'.format(action))
|
||||
raise ValueError(f'Unknown key action: {action}')
|
||||
|
||||
if not isinstance(args, (list, tuple)):
|
||||
args = (args, )
|
||||
|
||||
Reference in New Issue
Block a user