Skip to content

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

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

@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
kazuki0824 pushed a commit to kazuki0824/rustworkx that referenced this pull request Apr 20, 2025
* Improvements for rustworkx.visit annotations

* Black

* Remove double import sys

* Add overloads

* Another fix

* Revert "Add overloads"

This reverts commit 499ea56.

* Revert visitor defaults
@IvanIsCoding IvanIsCoding deleted the even-more-visit-annotation-fixes branch May 17, 2025 18:00
SILIZ4 pushed a commit to SILIZ4/rustworkx that referenced this pull request Jul 4, 2025
* Improvements for rustworkx.visit annotations

* Black

* Remove double import sys

* Add overloads

* Another fix

* Revert "Add overloads"

This reverts commit 499ea56.

* Revert visitor defaults
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