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

Improvements for rustworkx.visit annotations #1362

Merged
merged 7 commits into from
Jan 15, 2025

Conversation

IvanIsCoding
Copy link
Collaborator

@IvanIsCoding IvanIsCoding commented Jan 15, 2025

Related to #1352 and #1361

This is kind of a mix of using TypeVar's default argument with some feedback to mitigate the issue introduced in #787 that made us realize that the order of the arguments in the signature was wrong

@IvanIsCoding IvanIsCoding changed the title Even more visit annotation fixes Improvements for rustworkx.visit annotations Jan 15, 2025
@@ -42,6 +39,11 @@ if sys.version_info >= (3, 13):
else:
from typing_extensions import TypeVar

if sys.version_info >= (3, 11):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not strictly necessary but I noticed we could refactor this to avoid depending on typing_extension for 3.13

rustworkx/rustworkx.pyi Outdated Show resolved Hide resolved
class StopSearch(Exception): ...
class PruneSearch(Exception): ...

_T = TypeVar("_T")
_T = TypeVar("_T", default=Any)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This silences pyright in strict mode like reported in #1352

rustworkx/rustworkx.pyi Outdated Show resolved Hide resolved
rustworkx/rustworkx.pyi Outdated Show resolved Hide resolved
rustworkx/rustworkx.pyi Outdated Show resolved Hide resolved
rustworkx/__init__.py Outdated Show resolved Hide resolved
@IvanIsCoding
Copy link
Collaborator Author

IvanIsCoding commented Jan 15, 2025

Overloading is harder than I thought. https://github.com/Qiskit/rustworkx/actions/runs/12780463862/job/35626988746 had quite a lot of errors.

Let's try to merge a smaller PR first with some obvious, correct improvements. I will study more on the overloads side to try to fix the issues in a separate PR.

edit: I described a possible fix in #1361 (comment). So indeed, we'll need a separate PR. Let's keep this one simple

@mtreinish mtreinish added this pull request to the merge queue Jan 15, 2025
Merged via the queue into Qiskit:main with commit 51e2830 Jan 15, 2025
31 checks passed
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