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..5ed6064d6 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -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/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/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index b7573fa42..aafecacbf 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -4,6 +4,7 @@ Next release .. All changes .. ----------- +- Support for Python 3.7 is dropped (:pull:`492`). - New :func:`.utils.discard_on_error` and matching argument to :meth:`.TimeSeries.transact` to avoid locking :class:`.TimeSeries` / :class:`.Scenario` on failed operations with :class:`.JDBCBackend` (:pull:`488`). .. _v3.7.0: diff --git a/doc/install.rst b/doc/install.rst index 1eeab697e..d7d0d7251 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -31,6 +31,11 @@ Use cases for installing ixmp directly include: Install system dependencies =========================== +Python +------ + +Python version 3.8 or later is required. + GAMS (required) --------------- diff --git a/ixmp/__init__.py b/ixmp/__init__.py index 9284fa64a..1c745a663 100644 --- a/ixmp/__init__.py +++ b/ixmp/__init__.py @@ -1,9 +1,5 @@ import logging - -try: - from importlib.metadata import PackageNotFoundError, version -except ImportError: # Python 3.7 - from importlib_metadata import PackageNotFoundError, version # type: ignore +from importlib.metadata import PackageNotFoundError, version from ixmp._config import config from ixmp.backend import BACKENDS, IAMC_IDX, ItemType diff --git a/pyproject.toml b/pyproject.toml index 304274c68..7b6bc5fc0 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 = [ @@ -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 = {}