Skip to content

Commit

Permalink
Renovations, 2024-10 (#35)
Browse files Browse the repository at this point in the history
* Add reformatting commit to .git-blame-ignore-revs

* Update pre-commit tools; reformat with ruff-format

* CI: test on Python 3.13

* Upgrade GitHub Actions versions
  • Loading branch information
akx authored Oct 11, 2024
1 parent f7e5d9d commit b933089
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Format with Black, with trailing commas
1851ed7a75dadd9bdbfc524dcf12e2fcb7f536a7
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ jobs:
python-version:
- '3.7'
- '3.11'
- '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
Expand All @@ -36,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/
Expand All @@ -69,7 +70,7 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
Expand Down
12 changes: 4 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
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_.*
args:
- --install-types
- --non-interactive
- --scripts-are-modules

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
6 changes: 1 addition & 5 deletions hai/boto3_multipart_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})",
Expand Down
4 changes: 1 addition & 3 deletions hai/rate_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ def tick(self) -> TickResult:

def __repr__(self) -> str:
state_text = "throttled" if not self.current_state else "open"
return (
f"<RateLimiter {state_text} (allowance {self.allowance}, rate {self.rate})>"
)
return f"<RateLimiter {state_text} (allowance {self.allowance}, rate {self.rate})>"


class MultiRateLimiter:
Expand Down
2 changes: 1 addition & 1 deletion hai_tests/test_multipart_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("...")
Expand Down
4 changes: 1 addition & 3 deletions hai_tests/test_pipe_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 1 addition & 3 deletions hai_tests/test_rate_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b933089

Please sign in to comment.