-
Notifications
You must be signed in to change notification settings - Fork 6
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
619 move to pyright #632
base: main
Are you sure you want to change the base?
619 move to pyright #632
Conversation
1bd5afb
to
48371ac
Compare
@callumforrester please let me know your thoughts |
@stan-dot I like where this is going, thanks |
ok will try to finish this today |
48371ac
to
d28365e
Compare
simmotor has adding an ignore line pending ophyd choosing a side here |
|
|
still one issue with the stomp instantiation from the CLI - what's your opinion @callumforrester ? |
src/blueapi/worker/task_worker.py
Outdated
@@ -95,7 +95,7 @@ def __init__( | |||
|
|||
self._tasks = {} | |||
|
|||
self._state = WorkerState.from_bluesky_state(ctx.run_engine.state) | |||
self._state = WorkerState.from_bluesky_state(ctx.run_engine.state) # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fixable by setting the return type of from_bluesky_state
, possibly including a cast
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will look into it
@@ -181,8 +182,8 @@ def mark_task_as_started(event: WorkerEvent, _: str | None) -> None: | |||
task_started.set() | |||
|
|||
LOGGER.info(f"Submitting: {trackable_task}") | |||
sub = self.worker_events.subscribe(mark_task_as_started) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: Moving this out of the try
block means a network error could potentially bring down the worker subprocess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the first look on it, to add a callback on a potential event is not a network event.
it is only the following line:
self._task_channel.put_nowait(trackable_task)
that does something that looks like network logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not network logic, that's adding to an internal queue. However, it is not just network logic you need to worry about: Anything that can throw an exception should go inside the try
block, since we don't want the subprocess to crash and leave the main process spinning.
@stan-dot: Maybe we should make the password a secret in a separate PR, in order to deal with the errors. It is not essential to adopting pyright. |
I'd agree with you, @callumforrester had this difference was between a 200 lines PR and 1k lines PR. it's 100 +- lines at the moment so easy to review. :( The errors are from pyright, so it makes sense to make this as a change
this soft maybe does not feel honest as we both know you'd abosolutely not allow for this to go in the same PR, so please skip the pleasantries and just tell me to raise an issue and make a PR... |
For the record it was a genuine maybe, I agree that those changes are tangentially related. I read them during review and decided not to contest them unless they caused problems. I am unable to commit the time to help you debug the error right now so I'm leaving it up to you whether you want to put time into debugging on your own or make an issue and defer until later. I am happy with either resolution. |
/workspaces/blueapi/src/blueapi/startup/simmotor.py:41:9 - error: Method "set" overrides class "SynAxis" in an incompatible manner
Return type mismatch: base method returns type "MoveStatus", override returns type "Status"
"Status" is not assignable to "MoveStatus" (reportIncompatibleMethodOverride)
/workspaces/blueapi/src/blueapi/startup/simmotor.py:70:14 - error: "MoveStatus" is not defined (reportUndefinedVariable)
/workspaces/blueapi/src/blueapi/startup/simmotor.py:93:36 - error: "MoveStatus" is not defined (reportUndefinedVariable)
/workspaces/blueapi/src/blueapi/startup/simmotor.py:94:16 - error: "MoveStatus" is not defined (reportUndefinedVariable)
/workspaces/blueapi/src/blueapi/worker/task_worker.py
/workspaces/blueapi/src/blueapi/worker/task_worker.py:99:54 - error: Argument of type "LoggingPropertyMachine | ProxyString | str" cannot be assigned to parameter "bluesky_state" of type "RawRunEngineState" in function "from_bluesky_state"
Type "LoggingPropertyMachine | ProxyString | str" is not assignable to type "RawRunEngineState"
Type "str" is not assignable to type "RawRunEngineState"
Type "str" is not assignable to type "type[ProxyString]"
Type "str" is not assignable to type "type[str]"
Type "str" is not assignable to type "type[PropertyMachine]" (reportArgumentType)
/workspaces/blueapi/tests/unit_tests/worker/devices.py
/workspaces/blueapi/tests/unit_tests/worker/devices.py:43:9 - error: Method "set" overrides class "Movable" in an incompatible manner
Return type mismatch: base method returns type "Status", override returns type "Status"
"Status" is incompatible with protocol "Status"
"exception" is an incompatible type
Type "(timeout: Unknown | None = None) -> (StatusTimeoutError | Exception | type[Exception] | None)" is not assignable to type "(timeout: float | None = 0) -> (BaseException | None)"
Function return type "StatusTimeoutError | Exception | type[Exception] | None" is incompatible with type "BaseException | None"
"bluesky.protocols.Status" is not assignable to "ophyd.status.Status"
"bluesky.protocols.Status" is not assignable to "ophyd.status.Status" (reportIncompatibleMethodOverride)
/workspaces/blueapi/tests/unit_tests/worker/devices.py:45:16 - error: Type "AdditionalUpdateStatus" is not assignable to return type "Status"
"AdditionalUpdateStatus" is not assignable to "Status" (reportReturnType)
7 errors, 0 warnings, 0 informations those are the errors, they are all grounded in the chaos around ophyd-vs-ophyd-async bluesky protocol import (SynAxis and worker devices cases), as well as with State tracking - EngineState and the application specific state, and the unexpected super_state_machine import - not maintained, afaik vendored in into Bluesky. either those are solved in a different PR or this PR is merged with 'ignore' flags. |
@stan-dot I am okay with ignore flags on ophyd (not ophyd-async) devices, this problem is probably related to bluesky/bluesky#1809 |
53dc1ad
to
5850a02
Compare
any idea why are the tests taking forever @callumforrester ? |
points that need addressing