Skip to content

Commit

Permalink
Switch to ruff for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
alisaifee committed Jan 18, 2023
1 parent 00251ce commit 68ee7f6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ jobs:
python -m pip install "pip<22"
python -m pip install --upgrade setuptools wheel
pip install --no-binary protobuf -r requirements/ci.txt
- name: Lint with flake8
- name: Lint with ruff
run: |
flake8 . --count --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10
ruff limits tests
- name: Lint with black
run: |
black limits tests --check
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
lint:
black --check limits tests
flake8 limits tests
ruff limits tests
mypy limits

lint-fix:
black tests limits
isort -r --profile=black tests limits
autoflake8 -i -r tests limits
ruff --fix limits tests
mypy limits
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.ruff]
line-length=100

3 changes: 1 addition & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
-r test.txt
-r docs.txt
autoflake8
black
flake8
ruff
isort
keyring
mypy
Expand Down
4 changes: 2 additions & 2 deletions tests/aio/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def test_fixed_window(self, uri, args, fixture):
storage = storage_from_string(uri, **args)
limiter = FixedWindowRateLimiter(storage)
limit = RateLimitItemPerSecond(10, 2)
async with async_window(1) as (start, end):
async with async_window(1) as (start, _):
assert all([await limiter.hit(limit) for _ in range(0, 10)])
assert not await limiter.hit(limit)
assert (await limiter.get_window_stats(limit)).remaining == 0
Expand Down Expand Up @@ -82,7 +82,7 @@ async def test_fixed_window_with_elastic_expiry_multiple_cost(
limiter = FixedWindowElasticExpiryRateLimiter(storage)
limit = RateLimitItemPerSecond(10, 2)
assert not await limiter.hit(limit, "k1", cost=11)
async with async_window(0) as (start, end):
async with async_window(0) as (_, end):
assert await limiter.hit(limit, "k2", cost=5)
assert (await limiter.get_window_stats(limit, "k2")).remaining == 5
assert (await limiter.get_window_stats(limit, "k2")).reset_time == end + 2
Expand Down

0 comments on commit 68ee7f6

Please sign in to comment.