Skip to content

Correct type hint #132

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

Merged
merged 1 commit into from
Jun 17, 2025
Merged

Correct type hint #132

merged 1 commit into from
Jun 17, 2025

Conversation

1Maxnet1
Copy link
Contributor

I was wondering about a warning my IDE showed me. However I think it came from this type hint. As the durations matrix may have set some values to None (at least for Valhalla that is sometimes the case), the type hint should be a Optional list of lists of Optional floats.

If I'm wrong, please let me know about it and you can of course just close the PR.

I was wondering about a warning my IDE showed me. However I think it came from this type hint. As the durations matrix may have set some values to None (at least for Valhalla that is sometimes the case), the type hint should be a Optional list of lists of Optional floats.
@mthh
Copy link
Owner

mthh commented Jun 17, 2025

Thanks!
Indeed, I've checked and this can be the case (at least with Valhalla); and it's also the case for the distances property.

I'm leaving an example here for the sake of transparency:

valhalla_client = Valhalla()
pts = [[-122.332070, 47.606210], [-122.200676, 47.610378], [-120, 45]]
mat1 = valhalla_client.matrix(pts, profile="auto")
print(mat1.durations)
print(mat1.distances)
# [[0, 1023, None], [980, 0, None], [None, None, 0]]
# [[0, 16844, None], [16136, 0, None], [None, None, 0]]

@mthh mthh merged commit 8799aea into mthh:master Jun 17, 2025
2 checks passed
mthh added a commit that referenced this pull request Jun 17, 2025
@1Maxnet1 1Maxnet1 deleted the patch-2 branch June 17, 2025 16:52
gmcrocetti pushed a commit to gmcrocetti/routingpy that referenced this pull request Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants