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

73
pyproject.toml

@ -45,40 +45,18 @@ Source = "https://git.cpi.imtek.uni-freiburg.de/CPI/superx-budget-overview.git" @@ -45,40 +45,18 @@ Source = "https://git.cpi.imtek.uni-freiburg.de/CPI/superx-budget-overview.git"
test = [
"pytest >=4.0.0",
"pytest-cov",
"pytest-icdiff",
"pytest-mock",
"pytest-randomly",
"tox",
]
dev = [
"black",
"flake8",
"flake8-comprehensions",
"flake8-bandit",
"isort >= 5.0.0",
"flit",
"keyring",
"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]
markers = [
"fun: marks tests as functional (deselect with '-m \"not fun\"')",
@ -86,3 +64,48 @@ markers = [ @@ -86,3 +64,48 @@ markers = [
addopts = [
"--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