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 mypy under rustworkx 0.13.0 #245

Merged
merged 1 commit into from
Jun 8, 2023
Merged

Fix mypy under rustworkx 0.13.0 #245

merged 1 commit into from
Jun 8, 2023

Conversation

garrison
Copy link
Member

@garrison garrison commented Jun 8, 2023

This fixes mypy when run with the most recent rustworkx release, 0.13.0. Without this, mypy errors with

circuit_knitting/utils/transforms.py:30: error: Module "rustworkx" has no attribute "connected_components"; maybe "BiconnectedComponents"?  [attr-defined]
circuit_knitting/utils/transforms.py:102: error: Need type annotation for "graph"  [var-annotated]
Found 2 errors in 1 file (checked 36 source files)

It's not clear to me, though, why these annotations are necessary. I expect there is a better solution.

@garrison garrison requested a review from mtreinish June 8, 2023 01:59
@garrison
Copy link
Member Author

garrison commented Jun 8, 2023

After opening this, I learned that rustworkx 0.13.0 introduced type annotations, but they are currently incomplete. Since this fixes CI, I am in favor of merging it in its current form.

@garrison garrison requested a review from caleb-johnson June 8, 2023 14:14
@garrison garrison marked this pull request as ready for review June 8, 2023 14:14
@@ -27,7 +27,7 @@
from collections.abc import Sequence, Iterable, Hashable, MutableMapping
from typing import NamedTuple

from rustworkx import PyGraph, connected_components
from rustworkx import PyGraph, connected_components # type: ignore[attr-defined]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this. I wonder how we can know when to remove it? Should we make an issue to keep up with this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't planning to make an issue because I don't think it is worth a strong reminder to fix it. If we notice that rustworkx has more complete type annotations once day and want to revert it, that's fine, but if we don't remember to, it's not really a big deal either.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok sounds good!

Copy link
Collaborator

@caleb-johnson caleb-johnson left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! We'll just check in on this when rustworkx has fully fleshed out their type hints

@garrison garrison merged commit e177d97 into main Jun 8, 2023
@garrison garrison deleted the fix-rustworkx-type-hints branch June 8, 2023 14:58
caleb-johnson pushed a commit that referenced this pull request Jun 11, 2023
garrison added a commit that referenced this pull request Jun 12, 2023
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