Skip to content

Commit

Permalink
Use equality instead of identity to compare types (#533)
Browse files Browse the repository at this point in the history
In some cases, possibly when MsgGenerator is defined or imported from
different modules, the types can be equivalent but are not the same
instance. In these cases, the identity check would fail and some plans
would be excluded where they shouldn't be. Using equality checks instead
mean it shouldn't matter where the MsgGenerator type was defined as all
instances should be equal.
  • Loading branch information
tpoliaw authored Jul 1, 2024
1 parent 2783092 commit 53bdbe2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/blueapi/core/bluesky_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _follows_bluesky_protocols(obj: Any) -> bool:

def is_bluesky_plan_generator(func: PlanGenerator) -> bool:
try:
return get_type_hints(func).get("return") is MsgGenerator
return get_type_hints(func).get("return") == MsgGenerator
except TypeError:
# get_type_hints fails on some objects (such as Union or Optional)
return False
Expand Down

0 comments on commit 53bdbe2

Please sign in to comment.