Skip to content

Commit

Permalink
chore: replace black with ruff as the formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
wood-push-melon committed May 22, 2024
1 parent 4fe89ef commit 0e10dfe
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
with:
provider: microk8s
channel: 1.28-strict/stable
juju-channel: 3.2
bootstrap-options: '--agent-version=3.2.0'
juju-channel: 3.4/stable
bootstrap-options: '--agent-version=3.4.2'

- name: Run integration tests
run: tox -e build-prerequisites,integration -- --model testing
Expand Down
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 24.4.0
hooks:
- id: black
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
Expand Down
1 change: 0 additions & 1 deletion fmt-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
black
ruff
1 change: 0 additions & 1 deletion lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
black
codespell
ruff
35 changes: 24 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@ show_missing = true
minversion = "6.0"
log_cli_level = "INFO"

# Formatting tools configuration
[tool.black]
line-length = 99
target-version = ["py310", "py311"]

# Linting tools configuration
# Linting and formatting tools configuration
[tool.ruff]
# Default settings: https://docs.astral.sh/ruff/configuration/
# Settings: https://docs.astral.sh/ruff/settings/
line-length = 99
include = ["pyproject.toml", "src/**/*.py", "tests/**/*.py", "lib/charms/glauth_utils/**/*.py"]
extend-exclude = ["__pycache__", "*.egg_info"]

[tool.ruff.lint]
# Rules: https://docs.astral.sh/ruff/rules/
select = ["E", "W", "F", "C", "N", "D", "I001"]
extend-ignore = [
ignore = [
"D100",
"D101",
"D102",
"D103",
"D105",
"D107",
"D203",
"D204",
"D213",
Expand All @@ -43,17 +51,22 @@ extend-ignore = [
"D408",
"D409",
"D413",
"E501",
"N818"
]
ignore = ["D100", "D101", "D102", "D103", "D105", "D107", "E501", "N818"]
extend-exclude = ["__pycache__", "*.egg_info"]
per-file-ignores = {"tests/*" = ["D100","D101","D102","D103","D104"]}

[tool.ruff.mccabe]
[tool.ruff.lint.flake8-copyright]
author = "Canonical Ltd."
notice-rgx = "Copyright\\s\\d{4}([-,]\\d{4})*\\s+%(author)s"

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"

# Type checking tools configuration
[tool.mypy]
pretty = true
python_version = "3.10"
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ deps =
pre-commit
mypy
types-PyYAML
-r{toxinidir}/fmt-requirements.txt
-r{toxinidir}/lint-requirements.txt
commands =
pre-commit install -t commit-msg

[testenv:fmt]
description = Apply coding style standards to code
description = Apply coding style standards
deps =
-r{toxinidir}/fmt-requirements.txt
commands =
black {[vars]all_path}
ruff --fix {[vars]all_path}
ruff format {[vars]all_path}

[testenv:lint]
description = Check code against coding style standards
Expand All @@ -54,8 +55,7 @@ commands =
--skip {toxinidir}/.mypy_cache \
--skip {toxinidir}/icon.svg

ruff {[vars]all_path}
black --check --diff {[vars]all_path}
ruff check --diff {[vars]all_path}

[testenv:build-prerequisites]
description = Install necessary Linux packages for python dependencies
Expand Down

0 comments on commit 0e10dfe

Please sign in to comment.