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

Update flashlight.py #4586

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Update flashlight.py #4586

wants to merge 2 commits into from

Conversation

omamkaz
Copy link
Contributor

@omamkaz omamkaz commented Dec 16, 2024

Just some tricks that I think might improve the code! :)

Description

Test Code

# Test code for the review of this PR

Type of change

Checklist

  • I signed the CLA.
  • I have performed a self-review of my own code

Screenshots

Additional details

Summary by Sourcery

Enhancements:

  • Refactor flashlight state management by introducing a private method _toggle_state to handle state changes, reducing code duplication.

## Just some tricks that I think might improve the code! :)
@FeodorFitsner
Copy link
Contributor

I'm wondering if flashlight is turned off on device side are we getting the state change back in Python code?

@omamkaz
Copy link
Contributor Author

omamkaz commented Dec 17, 2024

I'm wondering if flashlight is turned off on device side are we getting the state change back in Python code?

Thanks, I think I made a mistake in the _toggle_state method so that the update will be like

def _toggle_state(self, sr: str, state: bool=True) -> bool:
    if ("1" == sr):
        self.turned_on = state
    return self.turned_on

Is it true or what?

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