Skip to content

feat: add major_version attribute to device initialization#119

Merged
robberwick merged 1 commit intoarvydas:release/2.0-devfrom
robberwick:blinkstick-device-major-version
Feb 16, 2025
Merged

feat: add major_version attribute to device initialization#119
robberwick merged 1 commit intoarvydas:release/2.0-devfrom
robberwick:blinkstick-device-major-version

Conversation

@robberwick
Copy link
Collaborator

This pull request includes an important change to the BlinkStickDevice class in the src/blinkstick/devices/device.py file. The change involves initializing the major_version attribute in the __post_init__ method.

  • src/blinkstick/devices/device.py: Added initialization of the major_version attribute in the __post_init__ method to ensure it is set based on the serial_details of the device.

@robberwick robberwick requested a review from Copilot February 16, 2025 09:44
Copy link

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 1 out of 1 changed files in this pull request and generated 1 comment.

@@ -20,6 +20,7 @@ class BlinkStickDevice(Generic[T]):
variant: BlinkStickVariant = field(init=False)

def __post_init__(self):
Copy link

Copilot AI Feb 16, 2025

Choose a reason for hiding this comment

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

Add a check to ensure serial_details is not None before accessing major_version to prevent potential AttributeError.

Suggested change
def __post_init__(self):
def __post_init__(self):
if self.serial_details is None:
raise ValueError("serial_details must not be None")

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@robberwick robberwick Feb 16, 2025

Choose a reason for hiding this comment

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

this is incorrect. serial_details is a required field of the dataclass, as a default is not provided in the decalration above, andit is not marked with Field(init=False)

@robberwick robberwick merged commit 23c5529 into arvydas:release/2.0-dev Feb 16, 2025
17 checks passed
@robberwick robberwick deleted the blinkstick-device-major-version branch February 16, 2025 09:49
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