From e1ec30de1ab856101f9268b12a59d91b8ad5c4dd Mon Sep 17 00:00:00 2001 From: Daniel Roschka Date: Tue, 26 Nov 2024 10:49:32 +0100 Subject: [PATCH 1/2] Update the pre-commit hooks --- .pre-commit-config.yaml | 6 +++--- xpartamupp/echelon.py | 4 +--- xpartamupp/elo.py | 2 +- xpartamupp/stanzas.py | 6 ++---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a70301..df64885 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -23,7 +23,7 @@ repos: - id: forbid-tabs - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.39.0 + rev: v0.43.0 hooks: - id: markdownlint @@ -42,7 +42,7 @@ repos: exclude: ^ejabberd_example.yml$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.5 + rev: v0.8.0 hooks: - id: ruff args: diff --git a/xpartamupp/echelon.py b/xpartamupp/echelon.py index 7258d95..0f57458 100755 --- a/xpartamupp/echelon.py +++ b/xpartamupp/echelon.py @@ -288,9 +288,7 @@ def _verify_game(game_report): jid for jid, state in game_report["playerStates"].items() if state == "won" ] # We only support 1v1s right now. - if len(winning_jids) > 1 or len(dict.keys(game_report["playerStates"])) != 2: - return False - return True + return len(winning_jids) == 1 and len(dict.keys(game_report["playerStates"])) == 2 def _rate_game(self, game): """Update player ratings based on game outcome. diff --git a/xpartamupp/elo.py b/xpartamupp/elo.py index 6162746..b31b96b 100644 --- a/xpartamupp/elo.py +++ b/xpartamupp/elo.py @@ -64,7 +64,7 @@ def get_rating_adjustment(rating, opponent_rating, games_played, _opponent_games """ if rating < -2199 or opponent_rating < -2199: raise ValueError( - "Too small rating given: rating: %i, opponent rating: %i" % (rating, opponent_rating) + f"Too small rating given: rating: {rating}, opponent rating: {opponent_rating}" ) rating_k_factor = ( diff --git a/xpartamupp/stanzas.py b/xpartamupp/stanzas.py index 4cc5471..5d50732 100644 --- a/xpartamupp/stanzas.py +++ b/xpartamupp/stanzas.py @@ -83,8 +83,7 @@ def get_game(self): data = {} if game is not None: - for key, item in game.items(): - data[key] = item + data = dict(game.items()) return data @@ -119,8 +118,7 @@ def get_game(self): data = {} if game is not None: - for key, item in game.items(): - data[key] = item + data = dict(game.items()) return data From 25568cab22a649c5f395cc9b09aef6ca5d6ec063 Mon Sep 17 00:00:00 2001 From: Daniel Roschka Date: Tue, 26 Nov 2024 10:49:36 +0100 Subject: [PATCH 2/2] Update the versions of the Github actions --- .github/workflows/pre-commit.yml | 6 ++++-- .github/workflows/unittests.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index e0cc8d3..6d3f992 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -8,5 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - - uses: pre-commit/action@v3.0.0 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 9e9b7b3..87f9ee1 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - name: Install tox