diff --git a/.flake8 b/.flake8 deleted file mode 100644 index b0c3b8d39..000000000 --- a/.flake8 +++ /dev/null @@ -1,8 +0,0 @@ -[flake8] -# FIXME the following exceed this limit -# .backend.io.s_read_excel: 26 -# .backend.jdbc.JDBCBackend.item_get_elements: 19 -# .core.scenario.Scenario.add_set: 17 -max-complexity = 15 -# For black -max-line-length = 88 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 0816b15fb..000000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: Lint - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - lint: - uses: iiasa/actions/.github/workflows/lint.yaml@main - with: - type-hint-packages: >- - genno - GitPython - nbclient - pytest - sphinx - xarray diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index f94990693..353109621 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -134,3 +134,13 @@ jobs: - name: Upload test coverage to Codecov.io uses: codecov/codecov-action@v3 + + pre-commit: + name: Code quality + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@v3.0.0 diff --git a/.gitignore b/.gitignore index e3e030b81..1ab84214a 100644 --- a/.gitignore +++ b/.gitignore @@ -50,8 +50,9 @@ rixmp/source/inst/docum/*.html # pytest and related .benchmarks .coverage* -.pytest_cache .mypy_cache +.pytest_cache +.ruff_cache *.pid coverage.xml htmlcov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..ccc97562f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +repos: +- repo: local + hooks: + - id: mypy + name: mypy + always_run: true + require_serial: true + pass_filenames: false + + language: python + entry: bash -c ". ${PRE_COMMIT_MYPY_VENV:-/dev/null}/bin/activate 2>/dev/null; mypy $0 $@" + additional_dependencies: + - mypy + - genno + - GitPython + - nbclient + - pytest + - sphinx + - xarray + args: ["."] +- repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.287 + hooks: + - id: ruff diff --git a/pyproject.toml b/pyproject.toml index 304274c68..1a75a90a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,12 +5,10 @@ requires = ["build", "setuptools-scm"] dynamic = ["version"] name = "ixmp" description = "The ix modeling platform" -authors = [ - { name = "IIASA Energy, Climate, and Environment (ECE) program" }, -] +authors = [{ name = "IIASA Energy, Climate, and Environment (ECE) program" }] maintainers = [ - {name = "Paul Natsuo Kishimoto", email = "mail@paul.kishimoto.name"}, - {name = "Fridolin Glatter", email = "glatter@iiasa.ac.at"}, + { name = "Paul Natsuo Kishimoto", email = "mail@paul.kishimoto.name" }, + { name = "Fridolin Glatter", email = "glatter@iiasa.ac.at" }, ] readme = "README.md" classifiers = [ @@ -75,9 +73,7 @@ tests = [ ixmp = "ixmp.cli:main" [tool.coverage.report] -omit = [ - "ixmp/utils/sphinx_linkcode_github.py", -] +omit = ["ixmp/utils/sphinx_linkcode_github.py"] [tool.isort] profile = "black" @@ -112,6 +108,16 @@ markers = [ "performance: ixmp performance test.", ] +[tool.ruff] +select = ["C9", "E", "F", "I", "W"] + +[tool.ruff.mccabe] +# FIXME the following exceed this limit +# .backend.io.s_read_excel: 26 +# .backend.jdbc.JDBCBackend.item_get_elements: 19 +# .core.scenario.Scenario.add_set: 17 +max-complexity = 15 + [tool.setuptools.packages] find = {}