From 1c1466aab2c8fcb56c722b8d5a8853e94b51a12a Mon Sep 17 00:00:00 2001 From: Ev-1 <33662061+Ev-1@users.noreply.github.com> Date: Sat, 9 Mar 2024 11:03:38 +0100 Subject: [PATCH] Update ruff and fix linting issues --- justfile | 2 +- musicbot/utils/localisation/localizer/localizer.py | 8 ++++---- pyproject.toml | 6 +++--- requirements.txt | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/justfile b/justfile index 24c3c64..fd98b64 100644 --- a/justfile +++ b/justfile @@ -30,7 +30,7 @@ clean: # Run ruff lint: venv - {{python}} -m ruff . --fix + {{python}} -m ruff check . --fix # Run tests test: venv diff --git a/musicbot/utils/localisation/localizer/localizer.py b/musicbot/utils/localisation/localizer/localizer.py index 8e4fb51..7d23576 100644 --- a/musicbot/utils/localisation/localizer/localizer.py +++ b/musicbot/utils/localisation/localizer/localizer.py @@ -78,7 +78,7 @@ def _load_localization(self, lang): def _parse_localization_dictionary(d, lookup, prefix=None): n_dict = {} for k, v in d.items(): - if type(v) is str: + if isinstance(v, str): n_dict[k] = Localizer._parse_localization_string(v, lookup, prefix) else: n_dict[k] = v @@ -137,11 +137,11 @@ def format_dict(self, d, lang=None, prefix=None, **kvpairs): cursorQueue = [nd] while cursorQueue: cursor = cursorQueue.pop() - for k, v in (cursor.items() if type(cursor) == dict else enumerate(cursor)): - if type(v) == str: + for k, v in (cursor.items() if isinstance(cursor, dict) else enumerate(cursor)): + if isinstance(v, str): # insert translations based on lang cursor[k] = self.format_str(v, lang, prefix, **kvpairs) - elif type(v) == dict or type(v) == list: + elif isinstance(v, dict) or isinstance(v, list): cursorQueue.append(v) return nd diff --git a/pyproject.toml b/pyproject.toml index ab151a6..3770942 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,11 +6,11 @@ pythonpath = ["."] [tool.ruff] # Allow lines to be as long as 120 characters. -select = ["F", "E", "B", "W", "I001"] +lint.select = ["F", "E", "B", "W", "I001"] line-length = 120 -[tool.ruff.isort] +[tool.ruff.lint.isort] section-order = ["future", "standard-library", "discord", "third-party", "first-party", "local-folder"] -[tool.ruff.isort.sections] +[tool.ruff.lint.isort.sections] "discord" = ["discord", "lavalink"] diff --git a/requirements.txt b/requirements.txt index a285722..eba5d03 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,5 @@ asyncio pyyaml BeautifulSoup4 pytest -ruff==0.0.274 +ruff pre-commit