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

Prepare refactoring of notifications (removal of NamedInts) #2630

Closed
wants to merge 11 commits into from

Conversation

rloutrel
Copy link
Contributor

#2273 : First 2 tests + add typing

Sorry, I could not understand how to use mock.Mock.

This could be merged already or wait for actual re-factoring that I will try to do next week.

@pfps
Copy link
Collaborator

pfps commented Oct 14, 2024

@MattHag Can you review this PR? I invited you into the project at a level that I think allows you to be a suggested reviewer.

@MattHag
Copy link
Collaborator

MattHag commented Oct 14, 2024

Yes

@pfps pfps requested a review from MattHag October 14, 2024 13:08
@pfps
Copy link
Collaborator

pfps commented Oct 14, 2024

@MattHag OK, I set you up as a reviewer.

Copy link
Collaborator

@MattHag MattHag left a comment

Choose a reason for hiding this comment

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

Looks good, but I have done some clean up and would to merge it right away.

Please enable this and I can merge it, afterwards
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

serial_reply = b"\x00\x00\x00\x00\x00\x00\x00\x00"
low_level_mock.read_register = mock.Mock(return_value=serial_reply)

receiver: Receiver = Receiver(MockLowLevelInterface(), None, {}, True, None, None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

mock.Mock() could be sufficient here, that's what I meant. But that's not so important and easy to change later on.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nevermind, it doesn't work with Mock alone.

@@ -55,29 +63,41 @@ def process(device, notification):
return _process_device_notification(device, notification)


def _process_receiver_notification(receiver, n):
def _process_receiver_notification(receiver: "Receiver", hidpp_notification: "HIDPPNotification") -> Optional[bool]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need strings here, when you import the modules for type checking, instead you add

from __future__ import annotations
and the following will work
def _process_receiver_notification(receiver: Receiver, hidpp_notification: HIDPPNotification) -> bool | None:

@rloutrel
Copy link
Contributor Author

Looks good, but I have done some clean up to merge it right away.

Please enable this and I can merge it, afterwards https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

It should already be activated. Is reviewer == maintainer ?

Did you already made the changes or shall I do it?

@MattHag
Copy link
Collaborator

MattHag commented Oct 14, 2024

I already did, let me try how this update works :)

@rloutrel
Copy link
Contributor Author

Ok I will tell you if my computer starts smoking because of you ;)

@MattHag
Copy link
Collaborator

MattHag commented Oct 14, 2024

Seems like I still can't push it. Here is the updated version
https://github.com/MattHag/Solaar/tree/rloutrel/master

@rloutrel
Copy link
Contributor Author

Shall we abandon this PR and PR the new branch then?

@MattHag
Copy link
Collaborator

MattHag commented Oct 14, 2024

Yes, if you don't mind.

@rloutrel rloutrel closed this Oct 14, 2024
@rloutrel
Copy link
Contributor Author

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.

3 participants