Skip to content

Commit b5ad9d2

Browse files
glatterf42khaeru
andauthored
Support mypy 1.12 (#882)
* 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 <[email protected]>
1 parent 7700a82 commit b5ad9d2

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
language: python
1111
entry: bash -c ". ${PRE_COMMIT_MYPY_VENV:-/dev/null}/bin/activate 2>/dev/null; mypy $0 $@"
1212
additional_dependencies:
13-
- mypy >= 1.9.0
13+
- mypy >= 1.12.0
1414
- asyncssh
1515
- git+https://github.com/iiasa/ixmp.git@main
1616
- importlib_resources
@@ -22,7 +22,7 @@ repos:
2222
- types-requests
2323
args: ["."]
2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: v0.3.4
25+
rev: v0.6.9
2626
hooks:
2727
- id: ruff
2828
- id: ruff-format

message_ix/tools/add_year/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ def add_year(
218218
cat_year_new: pd.DataFrame = sc_new.set("cat_year")
219219
firstmodelyear_new = cat_year_new.query("type_year == 'firstmodelyear'")
220220
firstyr_new: int = (
221-
min(cat_year_new["year"])
221+
int(min(cat_year_new["year"]))
222222
if firstmodelyear_new.empty
223-
else firstmodelyear_new["year"]
223+
else int(firstmodelyear_new["year"].item())
224224
) # type: ignore
225225
# assert isinstance(firstyear_new, int)
226226

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ omit = [
8888

8989
[tool.mypy]
9090
exclude = ["doc/"]
91+
# TODO Remove this once it has become default with mypy 2.0:
92+
local_partial_types = true
9193

9294
[[tool.mypy.overrides]]
9395
# Packages/modules for which no type hints are available.

tutorial/westeros/westeros_report.ipynb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,12 @@
118118
"rep.add(\"A\", 1)\n",
119119
"rep.add(\"B\", 2)\n",
120120
"\n",
121+
"\n",
121122
"# Add one node and two edges\n",
122123
"def add(*inputs):\n",
123124
" return sum(inputs)\n",
124125
"\n",
126+
"\n",
125127
"rep.add(\"C\", add, \"A\", \"B\")"
126128
]
127129
},
@@ -284,6 +286,7 @@
284286
"def ratio(a, b):\n",
285287
" return a / b\n",
286288
"\n",
289+
"\n",
287290
"# Add your code here:"
288291
]
289292
},

0 commit comments

Comments
 (0)