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

Rationalise accessing of read-only device attributes by use of a BlinkStickDevice class #110

Merged
merged 5 commits into from
Nov 30, 2024

Conversation

robberwick
Copy link
Collaborator

This pull request introduces significant changes to the BlinkStick backend classes by refactoring how devices are represented and managed. The most important changes include the introduction of a new BlinkStickDevice class, renaming and modifying methods to improve clarity and functionality, and updating the backend classes to utilize the new device representation.

Introduction of BlinkStickDevice class:

  • src/blinkstick/devices/device.py: Added a new BlinkStickDevice class to encapsulate device properties such as raw_device, serial, manufacturer, version_attribute, and description.

Refactoring backend classes:

Updates to BlinkStick class:

  • src/blinkstick/blinkstick.py: Updated the BlinkStick class to accept BlinkStickDevice in its constructor and modified the find_all and find_first methods to use the new get_attached_blinkstick_devices method. [1] [2] [3] [4]

These changes improve the maintainability and clarity of the codebase by introducing a clear device representation and refactoring methods for better readability and functionality.

Rename `find_blinksticks` to `get_attached_blinkstick_devices`, and `_refresh_device` to `_refresh_attached_blinkstick_device`
Always return a list from the usb backend, so if no blinkstick devices are detected, the list should be empty
@robberwick robberwick requested a review from Copilot November 30, 2024 17:01
@robberwick robberwick marked this pull request as ready for review November 30, 2024 17:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 suggestion.

Comments skipped due to low confidence (1)

src/blinkstick/backends/base.py:21

  • [nitpick] The method name '_refresh_attached_blinkstick_device' is too verbose. Consider renaming it to '_refresh_blinkstick_device' for conciseness.
def _refresh_attached_blinkstick_device(self):

src/blinkstick/backends/unix_like.py Outdated Show resolved Hide resolved
Use the BlinkStickDevice class to retrieve readonly device data up front, and persist it in the BlinkStick wrapper class

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (2)

src/blinkstick/blinkstick.py:1425

  • The variable 'd' should be renamed to 'blinkstick_devices' to match the updated variable name.
if d:

src/blinkstick/blinkstick.py:1427

  • The variable 'd' should be renamed to 'blinkstick_devices[0]' to match the updated variable name.
return BlinkStick(device=d)
Use the BlinkStickDevice class to retrieve readonly device data up front, and persist it in the BlinkStick wrapper class
@robberwick robberwick merged commit 5dde1b5 into arvydas:release/2.0-dev Nov 30, 2024
17 checks passed
@robberwick robberwick deleted the blinkstick-device branch November 30, 2024 18:44
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.

1 participant