mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-05 15:03:33 +08:00
Lint fixes for latest pylint (2.11.1)
This commit is contained in:
parent
934e66eb6c
commit
29dba11335
@ -301,6 +301,7 @@ def timestring(timeval: float,
|
|||||||
|
|
||||||
# We add seconds if its non-zero *or* we haven't added anything else.
|
# We add seconds if its non-zero *or* we haven't added anything else.
|
||||||
if centi:
|
if centi:
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
sval = (timeval / 1000.0 % 60.0)
|
sval = (timeval / 1000.0 % 60.0)
|
||||||
if sval >= 0.005 or not bits:
|
if sval >= 0.005 or not bits:
|
||||||
bits.append('${S}')
|
bits.append('${S}')
|
||||||
|
|||||||
@ -278,7 +278,7 @@ class DirectoryScan:
|
|||||||
else:
|
else:
|
||||||
fpath = pathlib.Path(moduledir, subpath, '__init__.py')
|
fpath = pathlib.Path(moduledir, subpath, '__init__.py')
|
||||||
ispackage = True
|
ispackage = True
|
||||||
with fpath.open() as infile:
|
with fpath.open(encoding='utf-8') as infile:
|
||||||
flines = infile.readlines()
|
flines = infile.readlines()
|
||||||
meta_lines = {
|
meta_lines = {
|
||||||
lnum: l[1:].split()
|
lnum: l[1:].split()
|
||||||
|
|||||||
@ -256,6 +256,7 @@ class ColorPickerExact(PopupWindow):
|
|||||||
|
|
||||||
# We generate these procedurally, so pylint misses them.
|
# We generate these procedurally, so pylint misses them.
|
||||||
# FIXME: create static attrs instead.
|
# FIXME: create static attrs instead.
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
ba.textwidget(edit=self._label_r, text='%.2f' % self._color[0])
|
ba.textwidget(edit=self._label_r, text='%.2f' % self._color[0])
|
||||||
ba.textwidget(edit=self._label_g, text='%.2f' % self._color[1])
|
ba.textwidget(edit=self._label_g, text='%.2f' % self._color[1])
|
||||||
ba.textwidget(edit=self._label_b, text='%.2f' % self._color[2])
|
ba.textwidget(edit=self._label_b, text='%.2f' % self._color[2])
|
||||||
|
|||||||
@ -784,12 +784,14 @@ class LeagueRankWindow(ba.Window):
|
|||||||
ba.buttonwidget(edit=self._activity_mult_button,
|
ba.buttonwidget(edit=self._activity_mult_button,
|
||||||
textcolor=(0.7, 0.7, 0.8, 1.0),
|
textcolor=(0.7, 0.7, 0.8, 1.0),
|
||||||
icon_color=(0.5, 0, 0.5, 1.0))
|
icon_color=(0.5, 0, 0.5, 1.0))
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
ba.textwidget(edit=self._activity_mult_text,
|
ba.textwidget(edit=self._activity_mult_text,
|
||||||
text='x ' + ('%.2f' % data['act']))
|
text='x ' + ('%.2f' % data['act']))
|
||||||
|
|
||||||
have_pro = False if data is None else data['p']
|
have_pro = False if data is None else data['p']
|
||||||
pro_mult = 1.0 + float(
|
pro_mult = 1.0 + float(
|
||||||
_ba.get_account_misc_read_val('proPowerRankingBoost', 0.0)) * 0.01
|
_ba.get_account_misc_read_val('proPowerRankingBoost', 0.0)) * 0.01
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
ba.textwidget(edit=self._pro_mult_text,
|
ba.textwidget(edit=self._pro_mult_text,
|
||||||
text=' -' if
|
text=' -' if
|
||||||
(data is None or not have_pro) else 'x ' +
|
(data is None or not have_pro) else 'x ' +
|
||||||
|
|||||||
@ -115,6 +115,7 @@ class TestingWindow(ba.Window):
|
|||||||
self._on_minus_press, entry['name']))
|
self._on_minus_press, entry['name']))
|
||||||
if i == 0:
|
if i == 0:
|
||||||
ba.widget(edit=btn, up_widget=self._back_button)
|
ba.widget(edit=btn, up_widget=self._back_button)
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
entry['widget'] = ba.textwidget(parent=self._subcontainer,
|
entry['widget'] = ba.textwidget(parent=self._subcontainer,
|
||||||
position=(h + 100, v),
|
position=(h + 100, v),
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
@ -155,18 +156,21 @@ class TestingWindow(ba.Window):
|
|||||||
for entry in self._entries:
|
for entry in self._entries:
|
||||||
_ba.value_test(entry['name'],
|
_ba.value_test(entry['name'],
|
||||||
absolute=ba.app.value_test_defaults[entry['name']])
|
absolute=ba.app.value_test_defaults[entry['name']])
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
ba.textwidget(edit=entry['widget'],
|
ba.textwidget(edit=entry['widget'],
|
||||||
text='%.4g' % _ba.value_test(entry['name']))
|
text='%.4g' % _ba.value_test(entry['name']))
|
||||||
|
|
||||||
def _on_minus_press(self, entry_name: str) -> None:
|
def _on_minus_press(self, entry_name: str) -> None:
|
||||||
entry = self._get_entry(entry_name)
|
entry = self._get_entry(entry_name)
|
||||||
_ba.value_test(entry['name'], change=-entry['increment'])
|
_ba.value_test(entry['name'], change=-entry['increment'])
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
ba.textwidget(edit=entry['widget'],
|
ba.textwidget(edit=entry['widget'],
|
||||||
text='%.4g' % _ba.value_test(entry['name']))
|
text='%.4g' % _ba.value_test(entry['name']))
|
||||||
|
|
||||||
def _on_plus_press(self, entry_name: str) -> None:
|
def _on_plus_press(self, entry_name: str) -> None:
|
||||||
entry = self._get_entry(entry_name)
|
entry = self._get_entry(entry_name)
|
||||||
_ba.value_test(entry['name'], change=entry['increment'])
|
_ba.value_test(entry['name'], change=entry['increment'])
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
ba.textwidget(edit=entry['widget'],
|
ba.textwidget(edit=entry['widget'],
|
||||||
text='%.4g' % _ba.value_test(entry['name']))
|
text='%.4g' % _ba.value_test(entry['name']))
|
||||||
|
|
||||||
|
|||||||
@ -125,7 +125,7 @@ def run(projroot: str, args: List[str]) -> None:
|
|||||||
# the project gradle file where we set it explicitly.
|
# the project gradle file where we set it explicitly.
|
||||||
if command == 'get-ndk-path':
|
if command == 'get-ndk-path':
|
||||||
gradlepath = Path(projroot, 'ballisticacore-android/build.gradle')
|
gradlepath = Path(projroot, 'ballisticacore-android/build.gradle')
|
||||||
with gradlepath.open() as infile:
|
with gradlepath.open(encoding='utf-8') as infile:
|
||||||
lines = [
|
lines = [
|
||||||
l for l in infile.readlines()
|
l for l in infile.readlines()
|
||||||
if l.strip().startswith('ext.ndk_version = ')
|
if l.strip().startswith('ext.ndk_version = ')
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class PipRequirement:
|
|||||||
# Note: we look directly for modules when possible instead of just pip
|
# Note: we look directly for modules when possible instead of just pip
|
||||||
# entries; this accounts for manual installations or other nonstandard setups.
|
# entries; this accounts for manual installations or other nonstandard setups.
|
||||||
PIP_REQUIREMENTS = [
|
PIP_REQUIREMENTS = [
|
||||||
PipRequirement(modulename='pylint', minversion=[2, 10, 2]),
|
PipRequirement(modulename='pylint', minversion=[2, 11, 1]),
|
||||||
PipRequirement(modulename='mypy', minversion=[0, 910]),
|
PipRequirement(modulename='mypy', minversion=[0, 910]),
|
||||||
PipRequirement(modulename='yapf', minversion=[0, 31, 0]),
|
PipRequirement(modulename='yapf', minversion=[0, 31, 0]),
|
||||||
PipRequirement(modulename='cpplint', minversion=[1, 5, 5]),
|
PipRequirement(modulename='cpplint', minversion=[1, 5, 5]),
|
||||||
|
|||||||
@ -201,6 +201,7 @@ def get_master_asset_src_dir() -> None:
|
|||||||
|
|
||||||
# Also compare repo name to split version of itself to
|
# Also compare repo name to split version of itself to
|
||||||
# see if we're outside of core (filtering will cause mismatch if so).
|
# see if we're outside of core (filtering will cause mismatch if so).
|
||||||
|
# pylint: disable=simplifiable-condition
|
||||||
if ('origin/master' in output.splitlines()[0]
|
if ('origin/master' in output.splitlines()[0]
|
||||||
and 'ballistica' + 'core' == 'ballisticacore'):
|
and 'ballistica' + 'core' == 'ballisticacore'):
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,8 @@ def enum_by_value(cls: Type[TENUM], value: Any) -> TENUM:
|
|||||||
to our objects sticking around longer than we want.
|
to our objects sticking around longer than we want.
|
||||||
This issue has been submitted to Python as a bug so hopefully we can
|
This issue has been submitted to Python as a bug so hopefully we can
|
||||||
remove this eventually if it gets fixed: https://bugs.python.org/issue42248
|
remove this eventually if it gets fixed: https://bugs.python.org/issue42248
|
||||||
|
UPDATE: This has been fixed as of later 3.8 builds, so we can kill this
|
||||||
|
off once we are 3.9+ across the board.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Note: we don't recreate *ALL* the functionality of the Enum constructor
|
# Note: we don't recreate *ALL* the functionality of the Enum constructor
|
||||||
@ -56,6 +58,7 @@ def enum_by_value(cls: Type[TENUM], value: Any) -> TENUM:
|
|||||||
assert isinstance(out, cls)
|
assert isinstance(out, cls)
|
||||||
return out
|
return out
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
raise ValueError('%r is not a valid %s' %
|
raise ValueError('%r is not a valid %s' %
|
||||||
(value, cls.__name__)) from None
|
(value, cls.__name__)) from None
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,8 @@ def getconfig(projroot: Path) -> Dict[str, Any]:
|
|||||||
def setconfig(projroot: Path, config: Dict[str, Any]) -> None:
|
def setconfig(projroot: Path, config: Dict[str, Any]) -> None:
|
||||||
"""Set the project config contents."""
|
"""Set the project config contents."""
|
||||||
os.makedirs(Path(projroot, 'config'), exist_ok=True)
|
os.makedirs(Path(projroot, 'config'), exist_ok=True)
|
||||||
with Path(projroot, 'config/config.json').open('w') as outfile:
|
with Path(projroot,
|
||||||
|
'config/config.json').open('w', encoding='utf-8') as outfile:
|
||||||
outfile.write(json.dumps(config, indent=2))
|
outfile.write(json.dumps(config, indent=2))
|
||||||
|
|
||||||
|
|
||||||
@ -200,7 +201,7 @@ def py_examine(projroot: Path, filename: Path, line: int, column: int,
|
|||||||
# Let's use ' flycheck_*' for the name since pipeline scripts
|
# Let's use ' flycheck_*' for the name since pipeline scripts
|
||||||
# are already set to ignore those files.
|
# are already set to ignore those files.
|
||||||
tmppath = Path(filename.parent, 'flycheck_mp_' + filename.name)
|
tmppath = Path(filename.parent, 'flycheck_mp_' + filename.name)
|
||||||
with tmppath.open('w') as outfile:
|
with tmppath.open('w', encoding='utf-8') as outfile:
|
||||||
outfile.write('\n'.join(flines))
|
outfile.write('\n'.join(flines))
|
||||||
try:
|
try:
|
||||||
code.runmypy(projroot, [str(tmppath)], check=False)
|
code.runmypy(projroot, [str(tmppath)], check=False)
|
||||||
|
|||||||
@ -32,15 +32,16 @@ class NoIndentEncoder(json.JSONEncoder):
|
|||||||
|
|
||||||
def default(self, o: Any) -> Any:
|
def default(self, o: Any) -> Any:
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
if isinstance(o, NoIndent):
|
if isinstance(o, NoIndent):
|
||||||
key = uuid.uuid4().hex
|
key = uuid.uuid4().hex
|
||||||
self._replacement_map[key] = json.dumps(o.value, **self.kwargs)
|
self._replacement_map[key] = json.dumps(o.value, **self.kwargs)
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
return '@@%s@@' % (key, )
|
return '@@%s@@' % (key, )
|
||||||
return super().default(o)
|
return super().default(o)
|
||||||
|
|
||||||
def encode(self, o: Any) -> Any:
|
def encode(self, o: Any) -> Any:
|
||||||
result = super().encode(o)
|
result = super().encode(o)
|
||||||
for k, v in self._replacement_map.items():
|
for k, v in self._replacement_map.items():
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
result = result.replace('"@@%s@@"' % (k, ), v)
|
result = result.replace('"@@%s@@"' % (k, ), v)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -366,7 +366,7 @@ def tool_config_install() -> None:
|
|||||||
|
|
||||||
print(f'Creating tool config: {Clr.BLD}{dst}{Clr.RST}')
|
print(f'Creating tool config: {Clr.BLD}{dst}{Clr.RST}')
|
||||||
|
|
||||||
with src.open() as infile:
|
with src.open(encoding='utf-8') as infile:
|
||||||
cfg = infile.read()
|
cfg = infile.read()
|
||||||
|
|
||||||
# Rome substitutions, etc.
|
# Rome substitutions, etc.
|
||||||
@ -385,7 +385,7 @@ def tool_config_install() -> None:
|
|||||||
cfg = (f'{comment} THIS FILE WAS AUTOGENERATED; DO NOT EDIT.\n'
|
cfg = (f'{comment} THIS FILE WAS AUTOGENERATED; DO NOT EDIT.\n'
|
||||||
f'{comment} Source: {src}.\n\n' + cfg)
|
f'{comment} Source: {src}.\n\n' + cfg)
|
||||||
|
|
||||||
with dst.open('w') as outfile:
|
with dst.open('w', encoding='utf-8') as outfile:
|
||||||
outfile.write(cfg)
|
outfile.write(cfg)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user