Skip to content

Commit

Permalink
Merge pull request #2136 from winged/feat_ruff
Browse files Browse the repository at this point in the history
Chore: Replace isort, flake8, black with ruff
  • Loading branch information
open-dynaMIX authored Jan 31, 2024
2 parents d833c82 + 99fa84e commit 8289ba3
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 303 deletions.
25 changes: 0 additions & 25 deletions .flake8

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ jobs:
- name: Run gitlint
run: poetry run gitlint --contrib contrib-title-conventional-commits

- name: Run black
run: poetry run black --check .
- name: Check code format
run: poetry run ruff format --check .

- name: Run flake8
run: poetry run flake8 --exclude .venv
- name: Check code style
run: poetry run ruff check .

- name: Run migration check
run: poetry run python manage.py makemigrations --check --dry-run --no-input
Expand Down
18 changes: 6 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
repos:
- repo: local
hooks:
- id: black
- id: ruff-format
stages: [commit]
name: black
name: format code
language: system
entry: black
entry: ruff format .
types: [python]
- id: isort
- id: ruff-check
stages: [commit]
name: isort
name: check format,import
language: system
entry: isort
types: [python]
- id: flake8
stages: [commit]
name: flake8
language: system
entry: flake8
entry: ruff check .
types: [python]
- id: reuse
stages: [commit]
Expand Down
1 change: 0 additions & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Files:
.dockerignore
.editorconfig
.env
.flake8
.github/dependabot.yml
.github/workflows/compatibility-tests.yml
.github/workflows/ghcr.yml
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ etc.

```bash
# linting
poetry run flake8
poetry run ruff check .
# format code
poetry run black .
poetry run ruff format .
# running tests
poetry run pytest
# create migrations
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://github.com/projectcaluma/caluma/workflows/Tests/badge.svg)](https://github.com/projectcaluma/caluma/actions?query=workflow%3ATests)
[![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/projectcaluma/caluma/blob/main/setup.cfg#L57)
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://docs.astral.sh/ruff/)
[![PyPI](https://img.shields.io/pypi/v/caluma)](https://pypi.org/project/caluma/)
[![License: GPL-3.0-or-later](https://img.shields.io/github/license/projectcaluma/caluma)](https://spdx.org/licenses/GPL-3.0-or-later.html)

Expand Down
6 changes: 5 additions & 1 deletion caluma/caluma_analytics/management/commands/run_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def _rowkey(val):
]
)
print(format_string.format(**col_labels))
print(format_string.format(**{k: "-" * l for k, l in col_lengths.items()}))
print(
format_string.format(
**{col: "-" * length for col, length in col_lengths.items()}
)
)

for rec in records:
fdata = {_rowkey(k): str(v) for k, v in rec.items()}
Expand Down
6 changes: 2 additions & 4 deletions caluma/caluma_core/tests/test_mutation_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ def check_perm(self, mutation, info):
}
}
}
""" % {
"form": form.slug
}
""" % {"form": form.slug}

result = schema_executor(query)
assert result.data == {
Expand All @@ -79,7 +77,7 @@ def check_perm(self, mutation, info):
assert len(params) == 1
assert len(params["input"]) == 3
assert params["input"]["slug"] == "email_addr"
assert type(params["input"]["format_validators"]) is list
assert isinstance(params["input"]["format_validators"], list)
return True

mocker.patch(f"{__name__}._TestPermission.permission_impl", check_perm)
Expand Down
4 changes: 2 additions & 2 deletions caluma/caluma_form/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def save_answer(
user: Optional[BaseUser] = None,
value: Optional[Any] = None,
context: Optional[dict] = None,
**kwargs
**kwargs,
) -> models.Answer:
"""
Save an answer for given question, document.
Expand All @@ -32,7 +32,7 @@ def save_default_answer(
question: models.Question,
user: Optional[BaseUser] = None,
value: Optional[Any] = None,
**kwargs
**kwargs,
) -> models.Answer:
"""
Save default_answer for given question.
Expand Down
2 changes: 1 addition & 1 deletion caluma/caluma_workflow/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def start_case(
form: Optional[Form] = None,
parent_work_item: Optional[models.WorkItem] = None,
context: Optional[dict] = None,
**kwargs
**kwargs,
) -> models.Case:
"""
Start a case of a given workflow (just like `saveCase`).
Expand Down
4 changes: 1 addition & 3 deletions caluma/caluma_workflow/tests/test_work_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,9 +1062,7 @@ def test_filter_document_has_answer(
}
}
}
""" % {
"filt": filt
}
""" % {"filt": filt}

result = schema_executor(
query,
Expand Down
5 changes: 3 additions & 2 deletions caluma/settings/caluma.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
This settings module only contains caluma specific settings.
Caluma specific settings.
It's imported by the main caluma settings and is intended to also be used by third party
This settings module only contains caluma-internal settings. It's imported
by the main caluma settings and is intended to also be used by third party
applications integrating Caluma.
"""

Expand Down
4 changes: 1 addition & 3 deletions caluma/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def test_schema_node(db, snapshot, request, node_type):
}
}
}
""" % {
"name": node_instance.__class__.__name__
}
""" % {"name": node_instance.__class__.__name__}

result = schema.execute(node_query, variable_values={"id": global_id})
assert not result.errors
Expand Down
Loading

0 comments on commit 8289ba3

Please sign in to comment.