From ad69fca1ad19c7c854691808a47ea5738ea1c110 Mon Sep 17 00:00:00 2001 From: akrherz Date: Sat, 16 Dec 2023 07:23:18 -0600 Subject: [PATCH 1/2] chore: format code with ruff --- .pre-commit-config.yaml | 7 ++----- pyproject.toml | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 698dbca..4c26ad6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,10 @@ ci: autoupdate_schedule: quarterly repos: - - repo: https://github.com/psf/black - rev: 23.10.0 - hooks: - - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.0" + rev: "v0.1.8" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 002b14f..14c942b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ -[tool.black] -line-length = 79 [tool.ruff] +line-length = 79 select = ["E", "F", "I"] target-version = "py39" From a46d877c426119100681843b420506d55838753c Mon Sep 17 00:00:00 2001 From: akrherz Date: Sat, 16 Dec 2023 07:25:32 -0600 Subject: [PATCH 2/2] mnt: address lint --- src/iembot/iemchatbot.py | 3 ++- src/iembot/util.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/iembot/iemchatbot.py b/src/iembot/iemchatbot.py index 348d1cf..e378dd5 100755 --- a/src/iembot/iemchatbot.py +++ b/src/iembot/iemchatbot.py @@ -205,7 +205,8 @@ def processMessagePC(self, elem): for user_id in self.md_routingtable.get(channel, []): if user_id not in self.md_users: log.msg( - f"Failed to send to Mastodon due to no access_tokens {user_id}" + "Failed to send to Mastodon due to no " + f"access_tokens {user_id}" ) continue # Require the x.twitter attribute to be set to prevent diff --git a/src/iembot/util.py b/src/iembot/util.py index 7a4acd3..0fe8b1d 100644 --- a/src/iembot/util.py +++ b/src/iembot/util.py @@ -117,7 +117,8 @@ def toot(bot, user_id, twttxt, **kwargs): api_base_url=bot.md_users[user_id]["api_base_url"], ) log.msg( - f"Sending to Mastodon {bot.md_users[user_id]['screen_name']}({user_id}) " + "Sending to Mastodon " + f"{bot.md_users[user_id]['screen_name']}({user_id}) " f"'{twttxt}' media:{kwargs.get('twitter_media')}" ) media = kwargs.get("twitter_media") @@ -142,7 +143,7 @@ def toot(bot, user_id, twttxt, **kwargs): time.sleep(kwargs.get("sleep", 10)) res = api.status_post(**params) except mastodon.errors.MastodonError as exp: - # Something else bad happened when submitting this to the Mastodon server + # Something else bad happened when submitting this to the Mastodon log.err(exp) params.pop("media_ids", None) # Try again without media # Since this called from a thread, sleeping should not jam us up