Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mypy checking #134

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
black . --check --diff
- name: Type check with mypy
run: |
mypy --install-types --non-interactive .
mypy .
Comment on lines +53 to 54
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first we run mypy just to see what types need to be installed, and install those types. Then we do the actual run

- name: Test with pytest
run: |
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ test = [
"flake8-pyproject",
"mypy",
"black",
"types-shapely",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shapely types aren't installed by default with the --install-types flag, so I install them explicitly for CI

]

[tool.setuptools]
Expand All @@ -58,7 +59,6 @@ extend-ignore = ["E203"] # See https://github.com/Py
exclude = ["build/", "venv/", "traveltimepy/proto/"]

[tool.mypy]
ignore_missing_imports = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we no longer need to ignore missing imports

exclude = "^(traveltimepy/proto/.*|build/.*|venv/.*)$"

[[tool.mypy.overrides]]
Expand Down
4 changes: 2 additions & 2 deletions traveltimepy/wkt/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _parse_polygon(geometry: Polygon) -> PolygonModel:
PointModel(coordinates=Coordinates(lat=lat, lng=lng))
for lat, lng in interior.coords
]
for interior in geometry.interiors
for interior in list(geometry.interiors)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing error

Item "List[LinearRing]" of "Union[Iterator[LinearRing], List[LinearRing]]" has no attribute "__next__"  [union-attr]

]
exterior_line = LineStringModel(coordinates=exterior_points)
interior_lines = [
Expand Down Expand Up @@ -123,7 +123,7 @@ def _parse_multi_polygon(geometry: MultiPolygon) -> MultiPolygonModel:
for point in interior.coords
],
)
for interior in polygon.interiors
for interior in list(polygon.interiors)
],
)
for polygon in geometry.geoms
Expand Down
Loading