Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce Ruff as linter #345

Merged
merged 6 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: Run yapf, isort, and flake8
- name: Run yapf, ruff, and mypy
run: |
poetry run tox -e yapf,isort,flake8,mypy
poetry run tox -e yapf,ruff,mypy
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies and build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
362 changes: 162 additions & 200 deletions poetry.lock

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,31 @@ redis = "*"
matplotlib = "*"

[tool.poetry.group.dev.dependencies]
pyproject-flake8 = "^6.1.0"
ruff = "*"
tox = "*"
moto = "*"
testfixtures = "*"
coverage = "*"
isort = "^5.7"
yapf = ">=0.32"
toml = "*"
lupa = "*"
fakeredis = "*"
mypy = "*"
types-redis = "*"

[tool.flake8]
[tool.ruff]
# All the rules are listed on https://docs.astral.sh/ruff/rules/
extend-select = [
"B", # bugbear
"I" # isort
]

# B006: Do not use mutable data structures for argument defaults. They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
# B008 Do not perform function calls in argument defaults. The call is performed only once at function definition time. All calls to your function will reuse the result of that definition-time function call. If this is intended, assign the function call to a module-level variable and use that variable as a default value.
# W503 line break before binary operator. We use W504(line break after binary operator) rather than W503
ignore = "B006,B008,W503"
max-line-length = 160
exclude = "venv/*,tox/*"
ignore = ["B006", "B008"]
Copy link
Collaborator Author

@hirosassa hirosassa Jan 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W503 is not currently supported in ruff and it will not be implemented.
ref: astral-sh/ruff#4125

Is anyone who want to ignore this error?


line-length = 160
exclude = ["venv/*", "tox/*"]

[tool.yapf]
based_on_style = "pep8"
Expand All @@ -64,9 +69,6 @@ ignore_patterns = [
"examples/*"
]

[tool.isort]
line_length = 160

[tool.mypy]
ignore_missing_imports = true

Expand Down
12 changes: 10 additions & 2 deletions test/test_redis_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@

import fakeredis

from gokart.redis_lock import (RedisClient, RedisParams, make_redis_key, make_redis_params, wrap_with_dump_lock, wrap_with_load_lock, wrap_with_remove_lock,
wrap_with_run_lock)
from gokart.redis_lock import (
RedisClient,
RedisParams,
make_redis_key,
make_redis_params,
wrap_with_dump_lock,
wrap_with_load_lock,
wrap_with_remove_lock,
wrap_with_run_lock,
)


class TestRedisClient(unittest.TestCase):
Expand Down
13 changes: 4 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{39,310,311,312},yapf,isort,flake8,mypy
envlist = py{39,310,311,312},yapf,ruff,mypy
isolated_build = true

[testenv]
Expand All @@ -12,15 +12,10 @@ allowlist_externals = yapf
skip_install = true
commands = yapf -dr . {posargs}

[testenv:isort]
allowlist_externals = isort
[testenv:ruff]
hirosassa marked this conversation as resolved.
Show resolved Hide resolved
allowlist_externals = ruff
skip_install = true
commands = isort -c gokart test {posargs}

[testenv:flake8]
allowlist_externals = pflake8
skip_install = true
commands = pflake8 gokart test {posargs}
commands = ruff check gokart test {posargs}

[testenv:mypy]
allowlist_externals = mypy
Expand Down