From 60ae752275c84744213ea94194586f55ae60f1f3 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 11 Oct 2024 12:41:39 +0300 Subject: [PATCH 1/4] Add reformatting commit to .git-blame-ignore-revs --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..1ae104a --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Format with Black, with trailing commas +1851ed7a75dadd9bdbfc524dcf12e2fcb7f536a7 From e60f1427f06addcfcc8cc9ea925a6eec1cca0f08 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 11 Oct 2024 13:05:31 +0300 Subject: [PATCH 2/4] Update pre-commit tools; reformat with ruff-format --- .pre-commit-config.yaml | 12 ++++-------- hai/boto3_multipart_upload.py | 6 +----- hai/rate_limiter.py | 4 +--- hai_tests/test_multipart_upload.py | 2 +- hai_tests/test_pipe_pump.py | 4 +--- hai_tests/test_rate_limiter.py | 4 +--- pyproject.toml | 2 ++ 7 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c8c53f7..3495a75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,23 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: - id: debug-statements - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.278 + rev: v0.6.9 hooks: - id: ruff args: - --fix - --exit-non-zero-on-fix + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.11.2 hooks: - id: mypy exclude: hai_tests/test_.* @@ -24,8 +25,3 @@ repos: - --install-types - --non-interactive - --scripts-are-modules - - - repo: https://github.com/psf/black - rev: 23.7.0 - hooks: - - id: black diff --git a/hai/boto3_multipart_upload.py b/hai/boto3_multipart_upload.py index f92f395..0cc5db0 100644 --- a/hai/boto3_multipart_upload.py +++ b/hai/boto3_multipart_upload.py @@ -161,11 +161,7 @@ def upload_file( maximum = min(S3_MAXIMUM_MULTIPART_CHUNK_SIZE, self.maximum_chunk_size) chunk_size = int(max(minimum, min(chunk_size, maximum))) - if ( - not S3_MINIMUM_MULTIPART_CHUNK_SIZE - <= chunk_size - < S3_MAXIMUM_MULTIPART_CHUNK_SIZE - ): + if not S3_MINIMUM_MULTIPART_CHUNK_SIZE <= chunk_size < S3_MAXIMUM_MULTIPART_CHUNK_SIZE: raise ValueError( f"Chunk size {chunk_size} is outside the protocol limits " f"({S3_MINIMUM_MULTIPART_CHUNK_SIZE}..{S3_MAXIMUM_MULTIPART_CHUNK_SIZE})", diff --git a/hai/rate_limiter.py b/hai/rate_limiter.py index 24bfdca..eb6ad9e 100644 --- a/hai/rate_limiter.py +++ b/hai/rate_limiter.py @@ -150,9 +150,7 @@ def tick(self) -> TickResult: def __repr__(self) -> str: state_text = "throttled" if not self.current_state else "open" - return ( - f"" - ) + return f"" class MultiRateLimiter: diff --git a/hai_tests/test_multipart_upload.py b/hai_tests/test_multipart_upload.py index a2b1cb5..cb9a914 100644 --- a/hai_tests/test_multipart_upload.py +++ b/hai_tests/test_multipart_upload.py @@ -34,7 +34,7 @@ def test_multipart_upload(tmpdir, file_type, mpu_class): file = temp_path.open("rb") elif file_type == "imaginary": expected_size = S3_MINIMUM_MULTIPART_FILE_SIZE * 2 - file = BytesIO(b"\xC0" * expected_size) + file = BytesIO(b"\xc0" * expected_size) file.seek(0) else: # pragma: no cover raise NotImplementedError("...") diff --git a/hai_tests/test_pipe_pump.py b/hai_tests/test_pipe_pump.py index b6c7e05..8651323 100644 --- a/hai_tests/test_pipe_pump.py +++ b/hai_tests/test_pipe_pump.py @@ -29,9 +29,7 @@ def add_handler(key, lines): [b"olleh", b"world"], # olleh due to mutation ] - assert ( - pp.get_value("stdout") == b"hello\ndlrow" - ) # and again re-reversed for the final list + assert pp.get_value("stdout") == b"hello\ndlrow" # and again re-reversed for the final list def test_chunk_pipe_pump(): diff --git a/hai_tests/test_rate_limiter.py b/hai_tests/test_rate_limiter.py index 1d2170c..956a9cc 100644 --- a/hai_tests/test_rate_limiter.py +++ b/hai_tests/test_rate_limiter.py @@ -31,9 +31,7 @@ def test_rate_limiter(): assert l.allowance < 1 # No tokens? r = l.tick() - assert ( - 1 <= l.allowance <= 2 - ) # We used one token in the tick, but one and some should be left + assert 1 <= l.allowance <= 2 # We used one token in the tick, but one and some should be left assert r assert r.did_change assert r.state_change == StateChange.BECAME_OPEN diff --git a/pyproject.toml b/pyproject.toml index ebebf3d..70cd417 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,8 @@ ignore_missing_imports = true [tool.ruff] target-version = "py37" line-length = 120 + +[tool.ruff.lint] mccabe.max-complexity = 10 select = [ "B", # bugbear From f0766f7735e558e67d91857bebacf7c2b28b5e67 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 11 Oct 2024 13:06:31 +0300 Subject: [PATCH 3/4] CI: test on Python 3.13 --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e980e4..14b29e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: python-version: - '3.7' - '3.11' + - '3.13' steps: - name: 'Set up Python ${{ matrix.python-version }}' uses: actions/setup-python@v4 From 19db619b8ba9b11ace6bfb195d6c31901a8b915b Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 11 Oct 2024 13:06:49 +0300 Subject: [PATCH 4/4] Upgrade GitHub Actions versions --- .github/workflows/ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14b29e6..2393590 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,13 +22,13 @@ jobs: - '3.13' steps: - name: 'Set up Python ${{ matrix.python-version }}' - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '${{ matrix.python-version }}' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: pip install -e . -r requirements-test.txt - run: py.test -vvv --cov . - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 env: BOTO_CONFIG: /dev/null AWS_SECRET_ACCESS_KEY: foobar_secret @@ -37,23 +37,23 @@ jobs: Lint: runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.11' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: pip install -e . pre-commit - run: pre-commit run --all-files Build: runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.11' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: pip install build - run: python -m build . - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: dist path: dist/ @@ -70,7 +70,7 @@ jobs: permissions: id-token: write steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: dist path: dist/