chore: Refactor type hinting in BaseBackend and its subclasses #107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TypeVar
andGeneric
to define a generic typeT
inBaseBackend
.T
to methods and attributes inBaseBackend
.Win32Backend
andUnixLikeBackend
to specify the type forT
.This pull request includes several changes to the
blinkstick
backends to improve type annotations and ensure type consistency across different backends. The most important changes include introducing generics to theBaseBackend
class, updating method return types, and adding type ignores for certain imports.Improvements to type annotations and consistency:
src/blinkstick/backends/base.py
: Introduced generics to theBaseBackend
class and updated method return types to use the new generic typeT
. [1] [2]src/blinkstick/backends/unix_like.py
: Updated theUnixLikeBackend
class to use theusb.core.Device
type for the generic parameterT
and updated method return types accordingly. [1] [2] [3]src/blinkstick/backends/win32.py
: Updated theWin32Backend
class to use thehid.HidDevice
type for the generic parameterT
, added type annotations for class attributes, and updated method return types accordingly. [1] [2] [3]src/blinkstick/backends/unix_like.py
andsrc/blinkstick/backends/win32.py
: Added# type: ignore
comments to suppress type checking forusb
andpywinusb
imports. [1] [2]src/blinkstick/blinkstick.py
: Improved thefind_all
method to handle cases where no devices are found by using a more concise and type-safe approach.