Skip to content

Commit b4d40a4

Browse files
committed
style: fix lints and format
1 parent d195f2a commit b4d40a4

File tree

6 files changed

+14
-22
lines changed

6 files changed

+14
-22
lines changed

docs_src/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
# add these directories to sys.path here. If the directory is relative to the
1515
# documentation root, use os.path.abspath to make it absolute, like shown here.
1616
#
17-
import os
1817
import sys
1918
from importlib import import_module
19+
from pathlib import Path
2020

21-
sys.path.insert(0, os.path.abspath(".."))
22-
sys.path.insert(0, os.path.abspath("."))
21+
sys.path.insert(0, Path("..").resolve().as_posix())
22+
sys.path.insert(0, Path().resolve().as_posix())
2323

2424
# -- Project information -----------------------------------------------------
2525

tests/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Value of "0" means it is NOT disabled
1010
os.environ["FRACTOPO_DISABLE_CACHE"] = "1"
1111

12+
import contextlib
1213
import logging
1314
import sys
1415
from functools import lru_cache, wraps
@@ -1675,14 +1676,10 @@ def get_all_errors():
16751676
)
16761677
all_errs = []
16771678
for err in all_error_types:
1678-
try:
1679+
with contextlib.suppress(KeyError):
16791680
all_errs.extend(generate_known_params(err, false_positive=False))
1680-
except KeyError:
1681-
pass
1682-
try:
1681+
with contextlib.suppress(KeyError):
16831682
all_errs.extend(generate_known_params(err, false_positive=True))
1684-
except KeyError:
1685-
pass
16861683

16871684
assert len(all_errs) > 0
16881685
return all_errs

tests/analysis/test_network.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def test_network(
242242

243243

244244
@tests.plotting_test
245-
def network_extensive_testing(
245+
def network_extensive_testing( # noqa: PLR0915
246246
network: Network,
247247
traces: gpd.GeoDataFrame,
248248
area: gpd.GeoDataFrame,
@@ -420,7 +420,7 @@ def test_network_circular_target_area(trace_gdf, area_gdf, name, data_regression
420420
)
421421

422422
# test both traces and branches for right boundary_intersect_counts
423-
for boundary_intersect_count, gdf, name in zip(
423+
for boundary_intersect_count, gdf, type_name in zip(
424424
(
425425
# network_circular.trace_boundary_intersect_count,
426426
# network_circular.branch_boundary_intersect_count,
@@ -435,8 +435,8 @@ def test_network_circular_target_area(trace_gdf, area_gdf, name, data_regression
435435
assert sum(boundary_intersect_count.values()) == gdf.shape[0]
436436
assert sum(gdf.geometry.intersects(area_gdf.geometry.iloc[0].boundary)) == sum(
437437
(
438-
boundary_intersect_count[f"{name} Boundary 1 Intersect Count"],
439-
boundary_intersect_count[f"{name} Boundary 2 Intersect Count"],
438+
boundary_intersect_count[f"{type_name} Boundary 1 Intersect Count"],
439+
boundary_intersect_count[f"{type_name} Boundary 2 Intersect Count"],
440440
)
441441
)
442442

tests/analysis/test_subsampling.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ def test_aggregate_chosen(
2525
for value in result.values():
2626
assert isinstance(value, value_type)
2727

28-
for col in assumed_results:
28+
for col, assumed_result_value in assumed_results.items():
2929
assert col in result
3030
result_value = result[col]
31-
assumed_result_value = assumed_results[col]
3231
if isinstance(result_value, str):
3332
assert result_value == assumed_result_value
3433
else:

tests/branches_and_nodes/test_branches_and_nodes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Tests for branch and node determination.
33
"""
44

5+
import contextlib
56
from typing import List
67

78
import geopandas as gpd
@@ -140,13 +141,11 @@ def test_crop_to_target_area(keep_column_data: bool):
140141
valid_areas_geoseries,
141142
)
142143
result = None
143-
try:
144+
with contextlib.suppress(TypeError):
144145
result = general.crop_to_target_areas(
145146
invalid_geoseries,
146147
invalid_areas_geoseries,
147148
)
148-
except TypeError:
149-
pass
150149
assert result is None
151150
assert isinstance(valid_result, (gpd.GeoDataFrame, gpd.GeoSeries))
152151
assert valid_geoseries.geometry.length.mean() > valid_result.geometry.length.mean()

tests/test_general.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ def test_match_crs(first, second, same: bool, from_first: bool, is_none: bool):
2525
"""
2626
Test match_crs with pytest params.
2727
"""
28-
if from_first:
29-
original_crs = first.crs
30-
else:
31-
original_crs = second.crs
28+
original_crs = first.crs if from_first else second.crs
3229
first_matched, second_matched = general.match_crs(first, second)
3330
if same:
3431
assert first_matched.crs == original_crs

0 commit comments

Comments
 (0)