Skip to content

Commit 09cf435

Browse files
authored
Drop support for Python 3.9, require >= 3.10 (#456)
Fix ruff for zip. Signed-off-by: Violeta Crespo Cobas <vcrespo@arfima.com>
1 parent cac5c10 commit 09cf435

35 files changed

+1343
-1629
lines changed

docs/user_guide/vulnerability/vulnerability_functions/multi_hazard_wri_power_generating_assets/onboard.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"df = pandas.read_csv(\"raw.csv\")\n",
3131
"df[\"Asset Type\"] = [\n",
3232
" (x if pandas.isna(y) else (x + \"/\" + y)).replace(\" \", \"\")\n",
33-
" for (x, y) in zip(df[\"Turbine Type\"], df[\"Cooling Technology\"])\n",
33+
" for (x, y) in zip(df[\"Turbine Type\"], df[\"Cooling Technology\"], strict=False)\n",
3434
"]\n",
3535
"df.drop(columns=[\"Turbine Type\", \"Cooling Technology\"], inplace=True)\n",
3636
"\n",

pdm.lock

Lines changed: 1202 additions & 1518 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ name = "physrisk-lib"
55
version = "1.0.12"
66
description = "OS-Climate Physical Risk Library"
77
authors = [
8-
{name = "Joe Moorhouse",email = "5102656+joemoorhouse@users.noreply.github.com"},
8+
{ name = "Joe Moorhouse", email = "5102656+joemoorhouse@users.noreply.github.com" },
99
]
10-
requires-python = ">=3.9"
10+
requires-python = ">=3.10"
1111
readme = "README.md"
12-
license = {file = "LICENSE"}
12+
license = { file = "LICENSE" }
1313
keywords = ["Physical", "Climate", "Risk", "Finance"]
1414

1515
classifiers = [
16-
"Intended Audience :: Developers",
17-
"Intended Audience :: Science/Research",
18-
"License :: OSI Approved :: Apache Software License",
19-
"Operating System :: MacOS",
20-
"Operating System :: Microsoft :: Windows",
21-
"Operating System :: Unix",
22-
"Programming Language :: Python",
23-
"Programming Language :: Python :: 3",
24-
"Programming Language :: Python :: 3 :: Only",
25-
"Programming Language :: Python :: 3.11",
26-
"Programming Language :: Python :: 3.10",
27-
"Programming Language :: Python :: 3.9",
28-
"Topic :: Office/Business :: Financial",
29-
"Topic :: Scientific/Engineering",
30-
"Topic :: Software Development",
16+
"Intended Audience :: Developers",
17+
"Intended Audience :: Science/Research",
18+
"License :: OSI Approved :: Apache Software License",
19+
"Operating System :: MacOS",
20+
"Operating System :: Microsoft :: Windows",
21+
"Operating System :: Unix",
22+
"Programming Language :: Python",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3 :: Only",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.10",
28+
"Topic :: Office/Business :: Financial",
29+
"Topic :: Scientific/Engineering",
30+
"Topic :: Software Development",
3131
]
3232

3333
dependencies = [
@@ -59,11 +59,7 @@ Documentation = "https://github.com/os-climate/physrisk/tree/main/docs"
5959
"Source Code" = "https://github.com/os-climate/physrisk"
6060

6161
[build-system]
62-
requires = [
63-
"setuptools>=42",
64-
"wheel",
65-
"pdm"
66-
]
62+
requires = ["setuptools>=42", "wheel", "pdm"]
6763
build-backend = "setuptools.build_meta"
6864

6965
[tool.setuptools]
@@ -80,16 +76,11 @@ physrisk = [
8076
"data/static/*.json",
8177
"data/static/example_portfolios/*.json",
8278
"data/static/hazard/*.json",
83-
"data/static/vulnerability/*.json"
79+
"data/static/vulnerability/*.json",
8480
]
8581

8682
[tool.pdm.dev-dependencies]
87-
test = [
88-
"pdm[pytest]",
89-
"pytest",
90-
"pytest-cov",
91-
"openpyxl>=3.1.5",
92-
]
83+
test = ["pdm[pytest]", "pytest", "pytest-cov", "openpyxl>=3.1.5"]
9384
doc = [
9485
"numpydoc",
9586
"nbsphinx",
@@ -108,12 +99,7 @@ doc = [
10899
"graphviz",
109100
"plotly>=5.24.1",
110101
]
111-
dev = [
112-
"mypy",
113-
"pre-commit",
114-
"ruff",
115-
"tox"
116-
]
102+
dev = ["mypy", "pre-commit", "ruff", "tox"]
117103

118104
[tool.pdm.scripts]
119105
pre_release = "scripts/dev-versioning.sh"
@@ -125,7 +111,7 @@ docs = { shell = "cd docs && make html", help = "Start the dev server for doc pr
125111
open_docs = { shell = "open ./docs/_build/html/index.html", help = "Start the dev server for doc preview" }
126112
lint = "pre-commit run --all-files"
127113
complete = { call = "tasks.complete:main", help = "Create autocomplete files for bash and fish" }
128-
all = {composite = ["pytest", "lint"]}
114+
all = { composite = ["pytest", "lint"] }
129115

130116
[tool.pytest.ini_options]
131117
testpaths = "tests"
@@ -152,13 +138,13 @@ skip_empty = true
152138
ignore_errors = true
153139
show_missing = true
154140
exclude_lines = [
155-
"pragma: no cover",
156-
"def __repr__",
157-
"if self.debug:",
158-
"raise NotImplementedError",
159-
"if __name__ == .__main__.:",
160-
"pass",
161-
"raise ImportError",
141+
"pragma: no cover",
142+
"def __repr__",
143+
"if self.debug:",
144+
"raise NotImplementedError",
145+
"if __name__ == .__main__.:",
146+
"pass",
147+
"raise ImportError",
162148
]
163149

164150
[tool.coverage.html]
@@ -198,14 +184,17 @@ exclude = [
198184
[tool.ruff.lint]
199185
extend-fixable = [
200186
# Instead of trailing-whitespace
201-
"W291", "W293"
202-
]
187+
"W291",
188+
"W293",
189+
]
203190

204191
extend-select = [
205192
# Instead of pydocstyle
206193
"D",
207194
#Instead of flake8
208-
"E", "F","B",
195+
"E",
196+
"F",
197+
"B",
209198
# Instead of pep8-naming
210199
"N",
211200
# Instead of flake8-debugger or debug-statements
@@ -220,7 +209,11 @@ ignore = [
220209
"D213",
221210

222211
# Ignore this rules so that precommit passes. Uncomment to start fixing them
223-
"B006", "B008", "B904", "B012", "B024",
212+
"B006",
213+
"B008",
214+
"B904",
215+
"B012",
216+
"B024",
224217
"D",
225218
]
226219

src/physrisk/data/geotiff_reader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def dataset_read_bounded(dataset, longitudes, latitudes, window_half_width=0.01)
4141
points,
4242
[
4343
[lon + offset[0], lat + offset[1]]
44-
for (lon, lat) in zip(longitudes, latitudes)
44+
for (lon, lat) in zip(longitudes, latitudes, strict=False)
4545
],
4646
)
4747

@@ -53,7 +53,7 @@ def dataset_read_bounded(dataset, longitudes, latitudes, window_half_width=0.01)
5353

5454

5555
def dataset_read_points(dataset, longitudes, latitudes, window_half_width=0.01):
56-
points = [[lon, lat] for (lon, lat) in zip(longitudes, latitudes)]
56+
points = [[lon, lat] for (lon, lat) in zip(longitudes, latitudes, strict=False)]
5757
samples = np.array(list(rasterio.sample.sample_gen(dataset, points)))
5858
return samples
5959

@@ -62,7 +62,7 @@ def dataset_read_windows(dataset, longitudes, latitudes, window_half_width=0.01)
6262
# seem to need to do one window at a time: potentially slow
6363
hw = window_half_width
6464
samples = []
65-
for lon, lat in zip(longitudes, latitudes):
65+
for lon, lat in zip(longitudes, latitudes, strict=False):
6666
win = rasterio.windows.from_bounds(
6767
lon - hw, lat - hw, lon + hw, lat + hw, dataset.transform
6868
) # left, bottom, right, top

src/physrisk/data/hazard_data_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ async def get_single_item(
423423
)
424424
)
425425
)
426-
for longitude, latitude in zip(longitudes, latitudes)
426+
for longitude, latitude in zip(longitudes, latitudes, strict=False)
427427
],
428428
self._interpolation,
429429
) # type: ignore

src/physrisk/data/inventory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ def expand(resources: List[HazardResource]) -> List[HazardResource]:
107107
scenario.periods.append(Period(year=year, map_id=id))
108108
# if a period was specified explicitly, we check that hash is the same: a build-in check
109109
if test_periods is not None:
110-
for period, test_period in zip(scenario.periods, test_periods):
110+
for period, test_period in zip(
111+
scenario.periods, test_periods, strict=False
112+
):
111113
if period.map_id != test_period.map_id:
112114
raise Exception(
113115
f"validation error: hash {period.map_id} different to specified hash {test_period.map_id}" # noqa: E501

src/physrisk/data/static/world.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_countries_json():
2525
countries = [
2626
Country(continent=continent, country=country, country_iso_a3=code)
2727
for (continent, country, code) in zip(
28-
world["continent"], world["name"], world["iso_a3"]
28+
world["continent"], world["name"], world["iso_a3"], strict=False
2929
)
3030
]
3131

src/physrisk/data/zarr_reader.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def get_max_curves(
264264
if multipoint.is_empty
265265
else multipoint
266266
)
267-
for shape, multipoint in zip(transformed_shapes, multipoints)
267+
for shape, multipoint in zip(transformed_shapes, multipoints, strict=False)
268268
]
269269
multipoints = [
270270
MultiPoint([(point.x, point.y)]) if isinstance(point, Point) else point
@@ -298,7 +298,7 @@ def get_max_curves(
298298
else MultiPoint(transformed_shape.exterior.coords)
299299
)
300300
for transformed_shape, multipoint in zip(
301-
transformed_shapes, multipoints
301+
transformed_shapes, multipoints, strict=False
302302
)
303303
]
304304
image_coords = np.array(
@@ -326,7 +326,9 @@ def get_max_curves(
326326
[
327327
np.nanmax(curves[index - number_of_points_per_shape : index, :], axis=0)
328328
for number_of_points_per_shape, index in zip(
329-
numbers_of_points_per_shape, numbers_of_points_per_shape_cumulated
329+
numbers_of_points_per_shape,
330+
numbers_of_points_per_shape_cumulated,
331+
strict=False,
330332
)
331333
]
332334
)

src/physrisk/hazard_models/jba_hazard_model.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ def get_hazard_data(
138138
)
139139
group_country_codes = self.geocoder.get_countries(group_lats, group_lons)
140140

141-
for country_code, cache_key in zip(group_country_codes, groups.keys()):
141+
for country_code, cache_key in zip(
142+
group_country_codes, groups.keys(), strict=False
143+
):
142144
request_groups[
143145
RequestKey(
144146
country_code=country_code, jba_scenario=cache_key.jba_scenario
@@ -230,7 +232,7 @@ async def flood_depth(
230232
"geometries": [
231233
{"id": id, "wkt_geometry": f"POINT({lon} {lat})", "buffer": 10}
232234
for id, lat, lon in zip(
233-
req_ids, api_request.latitudes, api_request.longitudes
235+
req_ids, api_request.latitudes, api_request.longitudes, strict=False
234236
)
235237
],
236238
}
@@ -262,7 +264,9 @@ def _identify_api_requests(
262264
# first checks cache
263265
cached_responses: Dict[JBACacheKey, Dict] = {
264266
cache_key: json.loads(item)
265-
for cache_key, item in zip(cache_keys, self.cache_store.getitems(cache_ids))
267+
for cache_key, item in zip(
268+
cache_keys, self.cache_store.getitems(cache_ids), strict=False
269+
)
266270
if item is not None
267271
}
268272
# we need to create requests for anything not in cache

src/physrisk/kernel/exposure.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def get_data_requests(
8484

8585
def get_exposures(self, asset: Asset, data_responses: Sequence[HazardDataResponse]):
8686
result: Dict[type, Tuple[Category, float, str]] = {}
87-
for (k, v), resp in zip(self.exposure_bins.items(), data_responses):
87+
for (k, v), resp in zip(
88+
self.exposure_bins.items(), data_responses, strict=False
89+
):
8890
if isinstance(resp, HazardParameterDataResponse):
8991
param = resp.parameter
9092
hazard_path = resp.path

0 commit comments

Comments
 (0)