Repository navigation
Allow plans with Concrete/non-Protocol parameters - #131
DiamondJoseph wants to merge 6 commits into
Conversation
- Replace use of Protocols that extend HasName with HasName - Use BaseModel.parse_obj instead of parse_obj_as - Spelling, grammar
Codecov Report
@@ Coverage Diff @@
## main #131 +/- ##
==========================================
+ Coverage 74.52% 75.47% +0.94%
==========================================
Files 37 37
Lines 1048 1060 +12
==========================================
+ Hits 781 800 +19
+ Misses 267 260 -7
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
callumforrester
left a comment
There was a problem hiding this comment.
Looks good to me, one minor nitpick and you can probably remove the TODOs, as explained in comments.
| @@ -0,0 +1,216 @@ | |||
| from typing import Any, Dict, Generator, List, Mapping, Optional | |||
There was a problem hiding this comment.
I think this file is better off in tests/core since the code it is testing is in src/core
| elif is_bluesky_compatible_device_type(field_type): | ||
| yield get_validator(plan_arg, field_type) | ||
|
|
||
| for k, v in Signature.from_callable(plan).parameters.items(): |
There was a problem hiding this comment.
This will fail if a plan has two arguments of the same type because utils.type_validator doesn't allow it. Example test case:
def concrete_plan_multi_arg(
motor_1: DelegatingNamedMovable,
motor_2: DelegatingNamedMovable,
) -> MsgGenerator: # type: ignore
...Presumably some sort of caching is needed
| def get_validators( | ||
| plan_arg: str, field_type: Type | ||
| ) -> Iterable[TypeValidatorDefinition]: | ||
| if isinstance(field_type, _GenericAlias): | ||
| for arg in get_args(field_type): | ||
| yield from get_validators(plan_arg, arg) | ||
| elif is_bluesky_compatible_device_type(field_type): | ||
| yield get_validator(plan_arg, field_type) |
There was a problem hiding this comment.
It feels like there should be a way to write a generic version of this in utils.type_validator, but I think it's fine to consider that out of scope. Mind making a ticket for it?
|
|
||
| for proto in BLUESKY_PROTOCOLS: | ||
| yield TypeValidatorDefinition(proto, get_device) | ||
| def plan_validators( |
There was a problem hiding this comment.
I think this function may grow and change and possibly be split up and recombined in all sorts of ways as we add more fancy plan parameter processing. Could we rename it to _plan_validators to discourage it's use outside this module for now?
|
Superceded by #154 |
Closes #117