Skip to content

Commit b84d60b

Browse files
fix(codeql): suppress lgtm warnings, remove dead code, simplify elif chain
- Add # lgtm[py/ineffectual-statement] to overload stubs in pipeline.py - Add # lgtm[py/bad-tag-filter] to _SUFFIX_RE in parser.py - Add # lgtm[py/empty-except] to intentional bare-pass except blocks in tests - Remove dead any_soda_results assignments in signs/__init__.py (L1/L2 branches) - Remove unused Transformer import and _transformer variable in build_index.py - Simplify redundant elif lower bounds in side_resolver.py (45<=angle<135 → angle<135) - Mirror all src changes to custom_components/asp_parking/gps2asp/ vendored copy Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 200ed75 commit b84d60b

11 files changed

Lines changed: 18 additions & 26 deletions

File tree

custom_components/asp_parking/gps2asp/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def resolve_asp(
2323
lon: float,
2424
debug: Literal[False] = ...,
2525
suspension_status: SuspensionInfo | None = ...,
26-
) -> ASPResult: ...
26+
) -> ASPResult: ... # lgtm[py/ineffectual-statement]
2727

2828

2929
@overload
@@ -32,7 +32,7 @@ async def resolve_asp(
3232
lon: float,
3333
debug: Literal[True],
3434
suspension_status: SuspensionInfo | None = ...,
35-
) -> ASPDebugResult: ...
35+
) -> ASPDebugResult: ... # lgtm[py/ineffectual-statement]
3636

3737

3838
async def resolve_asp(

custom_components/asp_parking/gps2asp/resolver/side_resolver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ def determine_side(
8181
if 315 <= angle or angle < 45:
8282
# Segment runs roughly East: left=N, right=S
8383
return "N" if cross > 0 else "S"
84-
elif 45 <= angle < 135:
84+
elif angle < 135:
8585
# Segment runs roughly North: left=W, right=E
8686
return "W" if cross > 0 else "E"
87-
elif 135 <= angle < 225:
87+
elif angle < 225:
8888
# Segment runs roughly West: left=S, right=N
8989
return "S" if cross > 0 else "N"
9090
else: # 225 <= angle < 315

custom_components/asp_parking/gps2asp/schedule/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
# Suffix: arrows (<->, -->) and optional SUPERSEDES clause.
6060
_SUFFIX_RE = re.compile(
61-
r"\s*(?:<-+>|--+>)\s*(?:\(SUPERSEDES\s+[^)]+\))?\s*$",
61+
r"\s*(?:<-+>|--+>)\s*(?:\(SUPERSEDES\s+[^)]+\))?\s*$", # lgtm[py/bad-tag-filter]
6262
re.IGNORECASE,
6363
)
6464

custom_components/asp_parking/gps2asp/signs/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ async def retrieve_signs(
276276
soda_level=1,
277277
)
278278
if result is not None:
279-
any_soda_results = True
280279
logger.info(
281280
"Level 1 matched: on_street=%r, from=%r, to=%r (%d unique signs)",
282281
on_variants[0],
@@ -313,7 +312,6 @@ async def retrieve_signs(
313312
soda_level=2,
314313
)
315314
if result is not None:
316-
any_soda_results = True
317315
logger.info(
318316
"Level 2 matched: on_street=%r, from=%r, to=%r (%d unique signs)",
319317
on_var,

scripts/build_index.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import geopandas as gpd
3030
import requests
3131
import zstandard
32-
from pyproj import Transformer
3332
from rtree import index as rtree_index
3433

3534
from gps2asp.signs.normalize import normalize_to_soda
@@ -51,9 +50,6 @@
5150
CSCL_BATCH_SIZE = 10000
5251
SIGNS_BATCH_SIZE = 50000
5352

54-
# WGS84 to EPSG:2263 transformer for reprojecting GeoJSON (which arrives in WGS84)
55-
_transformer = Transformer.from_crs("EPSG:4326", "EPSG:2263", always_xy=True)
56-
5753

5854
def _normalize_street_name(name: str) -> str:
5955
"""Normalize a street name by expanding abbreviations and directional prefixes.

src/gps2asp/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def resolve_asp(
2323
lon: float,
2424
debug: Literal[False] = ...,
2525
suspension_status: SuspensionInfo | None = ...,
26-
) -> ASPResult: ...
26+
) -> ASPResult: ... # lgtm[py/ineffectual-statement]
2727

2828

2929
@overload
@@ -32,7 +32,7 @@ async def resolve_asp(
3232
lon: float,
3333
debug: Literal[True],
3434
suspension_status: SuspensionInfo | None = ...,
35-
) -> ASPDebugResult: ...
35+
) -> ASPDebugResult: ... # lgtm[py/ineffectual-statement]
3636

3737

3838
async def resolve_asp(

src/gps2asp/resolver/side_resolver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ def determine_side(
8787
if 315 <= angle or angle < 45:
8888
# Segment runs roughly East: left=N, right=S
8989
return "N" if cross > 0 else "S"
90-
elif 45 <= angle < 135:
90+
elif angle < 135:
9191
# Segment runs roughly North: left=W, right=E
9292
return "W" if cross > 0 else "E"
93-
elif 135 <= angle < 225:
93+
elif angle < 225:
9494
# Segment runs roughly West: left=S, right=N
9595
return "S" if cross > 0 else "N"
9696
else: # 225 <= angle < 315

src/gps2asp/schedule/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
# Suffix: arrows (<->, -->) and optional SUPERSEDES clause.
6060
_SUFFIX_RE = re.compile(
61-
r"\s*(?:<-+>|--+>)\s*(?:\(SUPERSEDES\s+[^)]+\))?\s*$",
61+
r"\s*(?:<-+>|--+>)\s*(?:\(SUPERSEDES\s+[^)]+\))?\s*$", # lgtm[py/bad-tag-filter]
6262
re.IGNORECASE,
6363
)
6464

src/gps2asp/signs/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ async def retrieve_signs(
279279
soda_level=1,
280280
)
281281
if result is not None:
282-
any_soda_results = True
283282
logger.info(
284283
"Level 1 matched: on_street=%r, from=%r, to=%r (%d unique signs)",
285284
on_variants[0],
@@ -316,7 +315,6 @@ async def retrieve_signs(
316315
soda_level=2,
317316
)
318317
if result is not None:
319-
any_soda_results = True
320318
logger.info(
321319
"Level 2 matched: on_street=%r, from=%r, to=%r (%d unique signs)",
322320
on_var,

tests/test_edge_cases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async def test_divided_road_eastern_parkway(self, spatial_index_dir):
189189
# are approximate, but it should resolve to something
190190
assert isinstance(result.on_street, str)
191191
assert len(result.on_street) > 0
192-
except (AmbiguousResolutionError, NoSegmentFoundError):
192+
except (AmbiguousResolutionError, NoSegmentFoundError): # lgtm[py/empty-except]
193193
pass
194194

195195

@@ -208,7 +208,7 @@ async def test_manhattan_midtown(self, spatial_index_dir):
208208
)
209209
assert isinstance(result.on_street, str)
210210
assert result.side_of_street in ("N", "S", "E", "W")
211-
except (AmbiguousResolutionError, NoSegmentFoundError):
211+
except (AmbiguousResolutionError, NoSegmentFoundError): # lgtm[py/empty-except]
212212
pass
213213

214214
async def test_queens_astoria(self, spatial_index_dir):
@@ -221,7 +221,7 @@ async def test_queens_astoria(self, spatial_index_dir):
221221
index_dir=spatial_index_dir,
222222
)
223223
assert isinstance(result.on_street, str)
224-
except (AmbiguousResolutionError, NoSegmentFoundError):
224+
except (AmbiguousResolutionError, NoSegmentFoundError): # lgtm[py/empty-except]
225225
pass
226226

227227
async def test_bronx_grand_concourse(self, spatial_index_dir):
@@ -234,5 +234,5 @@ async def test_bronx_grand_concourse(self, spatial_index_dir):
234234
index_dir=spatial_index_dir,
235235
)
236236
assert isinstance(result.on_street, str)
237-
except (AmbiguousResolutionError, NoSegmentFoundError):
237+
except (AmbiguousResolutionError, NoSegmentFoundError): # lgtm[py/empty-except]
238238
pass

0 commit comments

Comments
 (0)