Skip to content

Commit

Permalink
use ruff instead of flake8 (#30)
Browse files Browse the repository at this point in the history
* use ruff instead of flake8

* remove complexity lint
  • Loading branch information
lucabello committed Apr 28, 2023
1 parent c274ad6 commit 3e18922
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 35 deletions.
27 changes: 10 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@ show_missing = true
line-length = 99
target-version = ["py38"]

[tool.isort]
profile = "black"

# Linting tools configuration
[tool.flake8]
max-line-length = 99
max-doc-length = 99
max-complexity = 10
exclude = [".git", "__pycache__", ".tox", "build", "dist", "*.egg_info", "venv"]
select = ["E", "W", "F", "C", "N", "R", "D", "H"]
# Ignore W503, E501 because using black creates errors with this
[tool.ruff]
line-length = 99
extend-exclude = ["__pycache__", "*.egg_info"]
select = ["E", "W", "F", "C", "N", "R", "D", "I001"]
# Ignore E501 because using black creates errors with this
# Ignore D107 Missing docstring in __init__
ignore = ["W503", "E501", "D107"]
ignore = ["E501", "D107", "RET504"]
# D100, D101, D102, D103: Ignore missing docstrings in tests
per-file-ignores = ["tests/*:D100,D101,D102,D103"]
docstring-convention = "google"
# Check for properly formatted copyright header in each file
copyright-check = "True"
copyright-author = "Canonical Ltd."
copyright-regexp = "Copyright\\s\\d{4}([-,]\\d{4})*\\s+%(author)s"
per-file-ignores = {"tests/*" = ["D100","D101","D102","D103"]}

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

# Static analysis tools configuration
[tool.mypy]
Expand Down
6 changes: 3 additions & 3 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _on_install(self, _) -> None:
def _has_metrics_providers(self):
"""Are any metrics providers available.
Returns
Returns:
-------
True if at least one metrics provider is related to this charm,
False otherwise.
Expand All @@ -103,7 +103,7 @@ def _has_metrics_providers(self):
def _has_metrics_consumers(self):
"""Are any metrics consumers available.
Returns
Returns:
-------
True if at least one metrics consumer is related to this charm,
False otherwise.
Expand Down Expand Up @@ -196,7 +196,7 @@ def _prometheus_configurations(self):
charm. The scrape jobs (including associated alert rules)
are returned.
Returns
Returns:
-------
A dictionary with keys "scrape_jobs" and "alert_rules".
"""
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
import typing
import unittest

from charm import PrometheusScrapeConfigCharm
from charms.observability_libs.v0.juju_topology import JujuTopology
from ops.model import ActiveStatus, BlockedStatus, WaitingStatus
from ops.testing import Harness

from charm import PrometheusScrapeConfigCharm


class TestCharm(unittest.TestCase):
@classmethod
Expand Down
17 changes: 4 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,20 @@ passenv =
description = Apply coding style standards to code
deps =
black
isort
ruff
commands =
isort {[vars]all_path}
ruff --fix {[vars]all_path}
black {[vars]all_path}

[testenv:lint]
description = Check code against coding style standards
deps =
black
flake8 < 5
flake8-docstrings
flake8-copyright
flake8-builtins
pyproject-flake8
pep8-naming
isort
ruff
codespell
commands =
codespell . --skip .git --skip .tox --skip build --skip lib --skip venv --skip .mypy_cache --skip *.svg

# pflake8 wrapper supports config from pyproject.toml
pflake8 {[vars]all_path}
isort --check-only --diff {[vars]all_path}
ruff {[vars]all_path}
black --check --diff {[vars]all_path}

[testenv:static-charm]
Expand Down

0 comments on commit 3e18922

Please sign in to comment.