diff --git a/assets/src/ba_data/python/ba/_gameutils.py b/assets/src/ba_data/python/ba/_gameutils.py index 16346d43..43901d2c 100644 --- a/assets/src/ba_data/python/ba/_gameutils.py +++ b/assets/src/ba_data/python/ba/_gameutils.py @@ -301,6 +301,7 @@ def timestring(timeval: float, # We add seconds if its non-zero *or* we haven't added anything else. if centi: + # pylint: disable=consider-using-f-string sval = (timeval / 1000.0 % 60.0) if sval >= 0.005 or not bits: bits.append('${S}') diff --git a/assets/src/ba_data/python/ba/_meta.py b/assets/src/ba_data/python/ba/_meta.py index 03865528..d3e7f4f1 100644 --- a/assets/src/ba_data/python/ba/_meta.py +++ b/assets/src/ba_data/python/ba/_meta.py @@ -278,7 +278,7 @@ class DirectoryScan: else: fpath = pathlib.Path(moduledir, subpath, '__init__.py') ispackage = True - with fpath.open() as infile: + with fpath.open(encoding='utf-8') as infile: flines = infile.readlines() meta_lines = { lnum: l[1:].split() diff --git a/assets/src/ba_data/python/bastd/ui/colorpicker.py b/assets/src/ba_data/python/bastd/ui/colorpicker.py index b9630a25..42cbb3a4 100644 --- a/assets/src/ba_data/python/bastd/ui/colorpicker.py +++ b/assets/src/ba_data/python/bastd/ui/colorpicker.py @@ -256,6 +256,7 @@ class ColorPickerExact(PopupWindow): # We generate these procedurally, so pylint misses them. # 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_g, text='%.2f' % self._color[1]) ba.textwidget(edit=self._label_b, text='%.2f' % self._color[2]) diff --git a/assets/src/ba_data/python/bastd/ui/league/rankwindow.py b/assets/src/ba_data/python/bastd/ui/league/rankwindow.py index 0ee0c9db..48bb1667 100644 --- a/assets/src/ba_data/python/bastd/ui/league/rankwindow.py +++ b/assets/src/ba_data/python/bastd/ui/league/rankwindow.py @@ -784,12 +784,14 @@ class LeagueRankWindow(ba.Window): ba.buttonwidget(edit=self._activity_mult_button, textcolor=(0.7, 0.7, 0.8, 1.0), icon_color=(0.5, 0, 0.5, 1.0)) + # pylint: disable=consider-using-f-string ba.textwidget(edit=self._activity_mult_text, text='x ' + ('%.2f' % data['act'])) have_pro = False if data is None else data['p'] pro_mult = 1.0 + float( _ba.get_account_misc_read_val('proPowerRankingBoost', 0.0)) * 0.01 + # pylint: disable=consider-using-f-string ba.textwidget(edit=self._pro_mult_text, text=' -' if (data is None or not have_pro) else 'x ' + diff --git a/assets/src/ba_data/python/bastd/ui/settings/testing.py b/assets/src/ba_data/python/bastd/ui/settings/testing.py index a96dd0d0..810311da 100644 --- a/assets/src/ba_data/python/bastd/ui/settings/testing.py +++ b/assets/src/ba_data/python/bastd/ui/settings/testing.py @@ -115,6 +115,7 @@ class TestingWindow(ba.Window): self._on_minus_press, entry['name'])) if i == 0: ba.widget(edit=btn, up_widget=self._back_button) + # pylint: disable=consider-using-f-string entry['widget'] = ba.textwidget(parent=self._subcontainer, position=(h + 100, v), size=(0, 0), @@ -155,18 +156,21 @@ class TestingWindow(ba.Window): for entry in self._entries: _ba.value_test(entry['name'], absolute=ba.app.value_test_defaults[entry['name']]) + # pylint: disable=consider-using-f-string ba.textwidget(edit=entry['widget'], text='%.4g' % _ba.value_test(entry['name'])) def _on_minus_press(self, entry_name: str) -> None: entry = self._get_entry(entry_name) _ba.value_test(entry['name'], change=-entry['increment']) + # pylint: disable=consider-using-f-string ba.textwidget(edit=entry['widget'], text='%.4g' % _ba.value_test(entry['name'])) def _on_plus_press(self, entry_name: str) -> None: entry = self._get_entry(entry_name) _ba.value_test(entry['name'], change=entry['increment']) + # pylint: disable=consider-using-f-string ba.textwidget(edit=entry['widget'], text='%.4g' % _ba.value_test(entry['name'])) diff --git a/tools/batools/androidsdkutils.py b/tools/batools/androidsdkutils.py index eda44e5f..5bfcebe5 100755 --- a/tools/batools/androidsdkutils.py +++ b/tools/batools/androidsdkutils.py @@ -125,7 +125,7 @@ def run(projroot: str, args: List[str]) -> None: # the project gradle file where we set it explicitly. if command == 'get-ndk-path': gradlepath = Path(projroot, 'ballisticacore-android/build.gradle') - with gradlepath.open() as infile: + with gradlepath.open(encoding='utf-8') as infile: lines = [ l for l in infile.readlines() if l.strip().startswith('ext.ndk_version = ') diff --git a/tools/batools/build.py b/tools/batools/build.py index 00551acb..18b3be97 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -31,7 +31,7 @@ class PipRequirement: # Note: we look directly for modules when possible instead of just pip # entries; this accounts for manual installations or other nonstandard setups. PIP_REQUIREMENTS = [ - PipRequirement(modulename='pylint', minversion=[2, 10, 2]), + PipRequirement(modulename='pylint', minversion=[2, 11, 1]), PipRequirement(modulename='mypy', minversion=[0, 910]), PipRequirement(modulename='yapf', minversion=[0, 31, 0]), PipRequirement(modulename='cpplint', minversion=[1, 5, 5]), diff --git a/tools/batools/pcommand.py b/tools/batools/pcommand.py index 0b40519f..87dc1d98 100644 --- a/tools/batools/pcommand.py +++ b/tools/batools/pcommand.py @@ -201,6 +201,7 @@ def get_master_asset_src_dir() -> None: # Also compare repo name to split version of itself to # see if we're outside of core (filtering will cause mismatch if so). + # pylint: disable=simplifiable-condition if ('origin/master' in output.splitlines()[0] and 'ballistica' + 'core' == 'ballisticacore'): diff --git a/tools/efro/util.py b/tools/efro/util.py index 162d2aab..61a8616a 100644 --- a/tools/efro/util.py +++ b/tools/efro/util.py @@ -45,6 +45,8 @@ def enum_by_value(cls: Type[TENUM], value: Any) -> TENUM: to our objects sticking around longer than we want. 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 + 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 @@ -56,6 +58,7 @@ def enum_by_value(cls: Type[TENUM], value: Any) -> TENUM: assert isinstance(out, cls) return out except KeyError: + # pylint: disable=consider-using-f-string raise ValueError('%r is not a valid %s' % (value, cls.__name__)) from None diff --git a/tools/efrotools/__init__.py b/tools/efrotools/__init__.py index db1546e3..fb80880a 100644 --- a/tools/efrotools/__init__.py +++ b/tools/efrotools/__init__.py @@ -60,7 +60,8 @@ def getconfig(projroot: Path) -> Dict[str, Any]: def setconfig(projroot: Path, config: Dict[str, Any]) -> None: """Set the project config contents.""" 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)) @@ -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 # are already set to ignore those files. 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)) try: code.runmypy(projroot, [str(tmppath)], check=False) diff --git a/tools/efrotools/jsontools.py b/tools/efrotools/jsontools.py index b1739704..9a6a011e 100644 --- a/tools/efrotools/jsontools.py +++ b/tools/efrotools/jsontools.py @@ -32,15 +32,16 @@ class NoIndentEncoder(json.JSONEncoder): def default(self, o: Any) -> Any: import uuid - if isinstance(o, NoIndent): key = uuid.uuid4().hex self._replacement_map[key] = json.dumps(o.value, **self.kwargs) + # pylint: disable=consider-using-f-string return '@@%s@@' % (key, ) return super().default(o) def encode(self, o: Any) -> Any: result = super().encode(o) for k, v in self._replacement_map.items(): + # pylint: disable=consider-using-f-string result = result.replace('"@@%s@@"' % (k, ), v) return result diff --git a/tools/efrotools/pcommand.py b/tools/efrotools/pcommand.py index 9df0497a..c8a2c011 100644 --- a/tools/efrotools/pcommand.py +++ b/tools/efrotools/pcommand.py @@ -366,7 +366,7 @@ def tool_config_install() -> None: 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() # Rome substitutions, etc. @@ -385,7 +385,7 @@ def tool_config_install() -> None: cfg = (f'{comment} THIS FILE WAS AUTOGENERATED; DO NOT EDIT.\n' 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)