Browse Source

switched to ruff for linting

main
Holger Frey 2 months ago
parent
commit
40565a6707
  1. 22
      Makefile
  2. 73
      pyproject.toml

22
Makefile

@ -51,33 +51,27 @@ clean-test: ## remove test and coverage artifacts
rm -fr htmlcov/ rm -fr htmlcov/
lint: ## reformat with black and check style with flake8 lint: ## reformat with black and check style with flake8
isort superx_budget .venv/bin/ruff format src tests noxfile.py
isort tests .venv/bin/ruff check src tests noxfile.py
black superx_budget tests
flake8 superx_budget tests
test: lint ## run tests quickly with the default Python test: lint ## run tests quickly with the default Python
pytest tests -x --disable-warnings -m "not fun" .venv/bin/pytest tests -x --disable-warnings -m "not fun"
testall: lint ## run tests quickly with the default Python testall: lint ## run tests quickly with the default Python
pytest tests .venv/bin/pytest tests
coverage: lint ## full test suite, check code coverage and open coverage report coverage: lint ## full test suite, check code coverage and open coverage report
pytest tests --cov=superx_budget -m "fun" .venv/bin/pytest tests --cov=superx_budget -m "fun"
coverage html .venv/bin/coverage html
$(BROWSER) htmlcov/index.html $(BROWSER) htmlcov/index.html
tox: ## run fully isolated tests with tox
tox
install: ## install updated project.toml with flint install: ## install updated project.toml with flint
flit install --pth-file .venv/bin/pip3 install -e ".[dev,test]"
devenv: ## setup development environment devenv: ## setup development environment
python3 -m venv --prompt superx_budget .venv python3 -m venv --prompt superx_budget .venv
.venv/bin/pip3 install --upgrade pip .venv/bin/pip3 install --upgrade pip
.venv/bin/pip3 install "flit>3.2" .venv/bin/pip3 install -e ".[dev,test]"
.venv/bin/flit install --pth-file
repo: devenv ## complete project setup with development environment and git repo repo: devenv ## complete project setup with development environment and git repo
git init . git init .

73
pyproject.toml

@ -45,40 +45,18 @@ Source = "https://git.cpi.imtek.uni-freiburg.de/CPI/superx-budget-overview.git"
test = [ test = [
"pytest >=4.0.0", "pytest >=4.0.0",
"pytest-cov", "pytest-cov",
"pytest-icdiff",
"pytest-mock", "pytest-mock",
"pytest-randomly", "pytest-randomly",
"tox", "tox",
] ]
dev = [ dev = [
"black", "flit",
"flake8",
"flake8-comprehensions",
"flake8-bandit",
"isort >= 5.0.0",
"keyring", "keyring",
"pre-commit", "pre-commit",
"ruff",
] ]
[tool.black]
line-length = 79
target-version = ['py37','py38', 'py39']
include = '\.pyi?$'
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
^/.git
^/.tox
^/.venv
^/.build
^/.dist
'''
[tool.isort]
line_length=79
multi_line_output=3
length_sort="True"
include_trailing_comma="True"
[tool.pytest.ini_options] [tool.pytest.ini_options]
markers = [ markers = [
"fun: marks tests as functional (deselect with '-m \"not fun\"')", "fun: marks tests as functional (deselect with '-m \"not fun\"')",
@ -86,3 +64,48 @@ markers = [
addopts = [ addopts = [
"--strict-markers", "--strict-markers",
] ]
[tool.ruff]
# see https://docs.astral.sh/ruff/configuration/
line-length = 80
indent-width = 4
fix = true
[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
fixable = ["ALL"]
select = ["ALL"]
ignore = [
# ignored for now, should be activated in the future
# docstrings
"D",
# don't complain about not annotating self or cls
"ANN101",
"ANN102",
# ignored, "ruff format" will handle this
"COM812",
"ISC001",
# ignored, due to Windows / WSL2 setup
# flake8-executable
"EXE",
]
[tool.ruff.lint.pydocstyle]
convention = "pep257" # Accepts: "google", "numpy", or "pep257".
[tool.ruff.lint.per-file-ignores]
# see https://github.com/charliermarsh/ruff
"tests/*" = ["FBT003", "INP001", "PLR2004", "S101", "SLF001", "ANN"]
"noxfile.py" = ["ANN"]
[tool.ruff.format]
indent-style = "space"
Loading…
Cancel
Save