diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ecc14114c..32c915cc7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: language: python entry: bash -c ". ${PRE_COMMIT_MYPY_VENV:-/dev/null}/bin/activate 2>/dev/null; mypy $0 $@" additional_dependencies: - - mypy >= 1.9.0 + - mypy >= 1.12.0 - asyncssh - git+https://github.com/iiasa/ixmp.git@main - importlib_resources @@ -22,7 +22,7 @@ repos: - types-requests args: ["."] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.4 + rev: v0.6.9 hooks: - id: ruff - id: ruff-format diff --git a/message_ix/tools/add_year/__init__.py b/message_ix/tools/add_year/__init__.py index c00b664fb..d0f593a11 100644 --- a/message_ix/tools/add_year/__init__.py +++ b/message_ix/tools/add_year/__init__.py @@ -218,9 +218,9 @@ def add_year( cat_year_new: pd.DataFrame = sc_new.set("cat_year") firstmodelyear_new = cat_year_new.query("type_year == 'firstmodelyear'") firstyr_new: int = ( - min(cat_year_new["year"]) + int(min(cat_year_new["year"])) if firstmodelyear_new.empty - else firstmodelyear_new["year"] + else int(firstmodelyear_new["year"].item()) ) # type: ignore # assert isinstance(firstyear_new, int) diff --git a/pyproject.toml b/pyproject.toml index 7d3625aee..ab8b7306d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,6 +88,8 @@ omit = [ [tool.mypy] exclude = ["doc/"] +# TODO Remove this once it has become default with mypy 2.0: +local_partial_types = true [[tool.mypy.overrides]] # Packages/modules for which no type hints are available. diff --git a/tutorial/westeros/westeros_report.ipynb b/tutorial/westeros/westeros_report.ipynb index 663193e9c..57ef40085 100644 --- a/tutorial/westeros/westeros_report.ipynb +++ b/tutorial/westeros/westeros_report.ipynb @@ -118,10 +118,12 @@ "rep.add(\"A\", 1)\n", "rep.add(\"B\", 2)\n", "\n", + "\n", "# Add one node and two edges\n", "def add(*inputs):\n", " return sum(inputs)\n", "\n", + "\n", "rep.add(\"C\", add, \"A\", \"B\")" ] }, @@ -284,6 +286,7 @@ "def ratio(a, b):\n", " return a / b\n", "\n", + "\n", "# Add your code here:" ] },