-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #492 from iiasa/enh/pre-commit
Use pre-commit to invoke ruff, mypy
- Loading branch information
Showing
9 changed files
with
73 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ concurrency: | |
cancel-in-progress: true | ||
|
||
env: | ||
# See description in lint.yml | ||
depth: 100 | ||
|
||
jobs: | ||
|
@@ -26,8 +25,7 @@ jobs: | |
- ubuntu-latest | ||
- windows-latest | ||
python-version: | ||
- "3.7" # Earliest version supported by ixmp | ||
- "3.8" | ||
- "3.8" # Earliest version supported by ixmp | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" # Latest supported by ixmp | ||
|
@@ -96,6 +94,9 @@ jobs: | |
- name: Install Python package and dependencies | ||
# [docs] contains [tests], which contains [report,tutorial] | ||
run: | | ||
# Work around https://bugs.launchpad.net/lxml/+bug/2035206 | ||
pip install "lxml != 4.9.3" | ||
pip install .[docs] | ||
# commented: use with "pandas-version" in the matrix, above | ||
|
@@ -134,3 +135,19 @@ 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 | ||
|
||
- name: Force recreation of pre-commit virtual environment for mypy | ||
if: github.event_name == 'schedule' | ||
run: gh cache list -L 999 | cut -f2 | grep pre-commit | xargs -I{} gh cache delete "{}" || true | ||
env: { GH_TOKEN: "${{ github.token }}" } | ||
|
||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = "[email protected]"}, | ||
{name = "Fridolin Glatter", email = "[email protected]"}, | ||
{ name = "Paul Natsuo Kishimoto", email = "[email protected]" }, | ||
{ name = "Fridolin Glatter", email = "[email protected]" }, | ||
] | ||
readme = "README.md" | ||
classifiers = [ | ||
|
@@ -22,7 +20,6 @@ classifiers = [ | |
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
|
@@ -31,11 +28,10 @@ classifiers = [ | |
"Topic :: Scientific/Engineering", | ||
"Topic :: Scientific/Engineering :: Information Analysis", | ||
] | ||
requires-python = ">=3.8" | ||
dependencies = [ | ||
"click", | ||
"genno <= 1.13; python_version < '3.8'", | ||
"genno >= 1.16; python_version >= '3.8'", | ||
"importlib_metadata; python_version < '3.8'", | ||
"genno >= 1.16", | ||
"JPype1 >= 1.2.1", | ||
"openpyxl", | ||
"pandas >= 1.2", | ||
|
@@ -75,9 +71,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 +106,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 = {} | ||
|
||
|