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

Fix OntologyGraph type annotations - breaking change #41

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

ielis
Copy link
Owner

@ielis ielis commented Sep 1, 2023

Correct the type annotations on OntologyGraph.get_children, OntologyGraph.get_parents, OntologyGraph.get_ancestors, OntologyGraph.get_descendants.

Previously, we promised iterables while the methods in fact provide iterators. This may have led to a bug if the iterator was used, e.g. within a nested loop:

hpo: MinimalOntology = ...

parents = hpo.graph.get_parents('HP:0001250')
for _ in range(5):
  for parent in parents:
    print(parent)

The loop above would, in fact, print only during the first iteration of the outer loop, and the iterator would be "consumed" for the remaining 4 iterations.

@ielis ielis changed the base branch from main to development September 1, 2023 19:06
@ielis ielis merged commit 99a212e into development Sep 1, 2023
@ielis ielis deleted the type-annotations branch September 1, 2023 19:08
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.

1 participant