Skip to content

Commit 2d45f52

Browse files
committed
Bump mypy, ruff versions
- ruff v1.9.0 → v1.14.1. - Drop custom hook entry that uses PRE_COMMIT_MYPY_VENV. - Use config suggested at python/mypy#13916. - ruff v0.3.4 → v0.9.1 - Reformat 4 files. - Temporarily exclude *.ipynb files covered by new version.
1 parent 3fa1191 commit 2d45f52

File tree

6 files changed

+22
-27
lines changed

6 files changed

+22
-27
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
repos:
2-
- repo: local
2+
- repo: https://github.com/pre-commit/mirrors-mypy
3+
rev: v1.14.1
34
hooks:
45
- id: mypy
5-
name: mypy
6-
always_run: true
7-
require_serial: true
86
pass_filenames: false
9-
10-
language: python
11-
entry: bash -c ". ${PRE_COMMIT_MYPY_VENV:-/dev/null}/bin/activate 2>/dev/null; mypy $0 $@"
127
additional_dependencies:
13-
- mypy >= 1.9.0
148
- genno
159
- GitPython
1610
- nbclient
1711
- pandas-stubs
1812
- pytest
19-
- sphinx
13+
- Sphinx
2014
- werkzeug
2115
- xarray
22-
args: ["."]
2316
- repo: https://github.com/astral-sh/ruff-pre-commit
24-
rev: v0.3.4
17+
rev: v0.9.1
2518
hooks:
2619
- id: ruff
2720
- id: ruff-format

ixmp/backend/jdbc.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _domain_enum(domain):
170170
return domain_enum.valueOf(domain.upper())
171171
except java.IllegalArgumentException:
172172
domains = ", ".join([d.name().lower() for d in domain_enum.values()])
173-
raise ValueError(f"No such domain: {domain}, " f"existing domains: {domains}")
173+
raise ValueError(f"No such domain: {domain}, existing domains: {domains}")
174174

175175

176176
def _unwrap(v):
@@ -886,8 +886,7 @@ def clone(
886886
# Raise exceptions for limitations of JDBCBackend
887887
if not isinstance(platform_dest._backend, self.__class__):
888888
raise NotImplementedError( # pragma: no cover
889-
f"Clone between {self.__class__} and"
890-
f"{platform_dest._backend.__class__}"
889+
f"Clone between {self.__class__} and{platform_dest._backend.__class__}"
891890
)
892891
elif platform_dest._backend is not self:
893892
package = s.__class__.__module__.split(".")[0]

ixmp/cli.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def report(context, config, key):
9191

9292
if not context:
9393
raise click.UsageError(
94-
"give either --url, --platform or --dbprops " "before command report"
94+
"give either --url, --platform or --dbprops before command report"
9595
)
9696

9797
# Instantiate the Reporter with the Scenario loaded by main()
@@ -227,8 +227,7 @@ def import_group(context):
227227
"""
228228
if not context or "scen" not in context:
229229
raise click.UsageError(
230-
"give --url, or --platform, --model, and "
231-
"--scenario, before command import"
230+
"give --url, or --platform, --model, and --scenario, before command import"
232231
)
233232

234233

@@ -407,7 +406,7 @@ def list_scenarios(context, **kwargs):
407406

408407
if not context:
409408
raise click.UsageError(
410-
"give either --url, --platform or --dbprops " "before command list"
409+
"give either --url, --platform or --dbprops before command list"
411410
)
412411

413412
print(

ixmp/tests/backend/test_jdbc.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@ def test_verbose_exception(test_mp, exception_verbose_true):
373373

374374
exc_msg = exc_info.value.args[0]
375375
assert (
376-
"There exists no Scenario 'foo|bar' "
377-
"(version: -1) in the database!" in exc_msg
376+
"There exists no Scenario 'foo|bar' (version: -1) in the database!" in exc_msg
378377
)
379378
assert "at.ac.iiasa.ixmp.database.DbDAO.getRunId" in exc_msg
380379
assert "at.ac.iiasa.ixmp.Platform.getScenario" in exc_msg
@@ -595,7 +594,7 @@ def test_reload_cycle(
595594
mp = ixmp.Platform(**platform_args)
596595

597596
# Load existing Scenario
598-
s0 = ixmp.Scenario(mp, model="foo", scenario=f"bar {i-1}", version=1)
597+
s0 = ixmp.Scenario(mp, model="foo", scenario=f"bar {i - 1}", version=1)
599598

600599
memory_usage(f"pass {i} -- platform instantiated")
601600

ixmp/tests/core/test_scenario.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_init_set(self, scen):
137137
# Add set on a locked scenario
138138
with pytest.raises(
139139
RuntimeError,
140-
match="This Scenario cannot be edited" ", do a checkout first!",
140+
match="This Scenario cannot be edited, do a checkout first!",
141141
):
142142
scen.init_set("foo")
143143

@@ -399,7 +399,7 @@ def test_excel_io(self, scen, scen_empty, tmp_path, caplog):
399399

400400
# With init_items=False, can't be read into an empty Scenario.
401401
# Exception raised is the first index set, alphabetically
402-
with pytest.raises(ValueError, match="no set 'i'; " "try init_items=True"):
402+
with pytest.raises(ValueError, match="no set 'i'; try init_items=True"):
403403
scen_empty.read_excel(tmp_path)
404404

405405
# File can be read with init_items=True
@@ -441,7 +441,7 @@ def test_excel_io(self, scen, scen_empty, tmp_path, caplog):
441441

442442
# Fails with add_units=False
443443
with pytest.raises(
444-
ValueError, match="The unit 'pounds' does not exist" " in the database!"
444+
ValueError, match="The unit 'pounds' does not exist in the database!"
445445
):
446446
s.read_excel(tmp_path, init_items=True)
447447

@@ -623,7 +623,7 @@ def test_set(scen_empty) -> None:
623623
scen.add_set("i", ["i9", "extra"], ["i9 comment"])
624624
# Missing element in the index set
625625
with pytest.raises(
626-
ValueError, match="The index set 'i' does not have an " "element 'bar'!"
626+
ValueError, match="The index set 'i' does not have an element 'bar'!"
627627
):
628628
scen.add_set("foo", "bar")
629629

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ exclude_also = [
8282
omit = ["ixmp/util/sphinx_linkcode_github.py"]
8383

8484
[tool.mypy]
85-
exclude = [
86-
"build/",
85+
files = [
86+
"doc",
87+
"ixmp",
8788
]
8889

8990
[[tool.mypy.overrides]]
@@ -111,6 +112,10 @@ markers = [
111112
]
112113
tmp_path_retention_policy = "none"
113114

115+
[tool.ruff]
116+
# TEMPORARY Exclude tutorial files
117+
extend-exclude = ["*.ipynb"]
118+
114119
[tool.ruff.lint]
115120
select = ["C9", "E", "F", "I", "W"]
116121
# FIXME the following exceed this limit

0 commit comments

Comments
 (0)