Skip to content

Commit

Permalink
Support mypy 1.12 (#882)
Browse files Browse the repository at this point in the history
* Enable soon-to-be-default mypy setting
* Cast silent-int values as int explicitly
* Bump mypy, ruff versions
- mypy v1.9.0 → v1.12.0
- ruff v0.3.4 → v0.6.9
* Apply latest ruff version to tutorial

---------

Co-authored-by: Paul Natsuo Kishimoto <mail@paul.kishimoto.name>
  • Loading branch information
glatterf42 and khaeru authored Oct 15, 2024
1 parent 7700a82 commit b5ad9d2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions message_ix/tools/add_year/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions tutorial/westeros/westeros_report.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
]
},
Expand Down Expand Up @@ -284,6 +286,7 @@
"def ratio(a, b):\n",
" return a / b\n",
"\n",
"\n",
"# Add your code here:"
]
},
Expand Down

0 comments on commit b5ad9d2

Please sign in to comment.