Skip to content
This repository was archived by the owner on Jul 27, 2020. It is now read-only.

✨ Adapter for Windows #9

Merged
merged 52 commits into from
Feb 27, 2020
Merged

✨ Adapter for Windows #9

merged 52 commits into from
Feb 27, 2020

Conversation

acabarbaye
Copy link
Contributor

Description

New adapter for Windows.

Caveat:
Some changes may be needed for ST boards as the serial port does not seem to be retrieved properly since I updated the USB drivers with Mbed Studio. Would be worth testing on a fresh Windows machine.

Test Coverage

  • This change is covered by existing or additional automated tests.
  • Manual testing has been performed (and evidence provided) as automated testing was not feasible.
  • Additional tests are not required for this change (e.g. documentation update).

@property
def filter(self) -> Optional[str]:
"""Filter applied on the list of elements."""
return None
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to improve the documentation

logger = logging.getLogger(__name__)


class ComponentDescriptor(ABC):
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm really struggling to understand what this object does and why we need all of this complexity. It seems like some sort of abstract factory class which instantiates a NamedTuple in a bunch of different ways, with some unexpected uses of @classmethod. Do we really need to make this so complex? I'd prefer some simple factory functions over this abstract factory (if that's what this is).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I radically changed the code to make it simpler to follow. Hopefully, I succeeded.

Copy link
Contributor

@muchzill4 muchzill4 left a comment

Choose a reason for hiding this comment

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

Now that I understand why hashing is necessary - I think it should be the responsibility of a single utility class to glue fetching and merging data together. In my mind this does not belong on a parent class that pollutes namespaces of all its children via inheritance. This functionality should be encapsulated and collaborate or be part of WindowsComponentDescriptor I suggested above. It's sole responsibility should be to crunch data returned by win32 lib and merge it.



class UsbIdentifier(
named_tuple_with_defaults( # type:ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only place named_tuple_with_defaults is ever used, also it sets all the values to None. Do you think it's necessary? Why would UsbIdentifier full of None even exist (be instantiated)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does not set all the values to None. Just the ones which were not provided. The reason this is done is that there is no rule about what elements are present in the DeviceID and what isn't

@acabarbaye
Copy link
Contributor Author

Due to the amount of review comments, I refactored drastically the code and will try to answer most change requests in this comment.

  1. The warning printing when run as part of pytest come form pywin32 dependency which I use to make the calls to the Windows system. I will not be able to change this.
  2. I reduced the number of #type: ignore to a handful and limited them to where I could not find any better ways.
  3. I'd prefer to keep the definitions of the different Win32 class as close as their definition in MSDN so that it is easy to follow and maintain in the future. It also makes it easier to debug.
    4.5. I refactored the code so that it uses composition rather than multiple inheritance. Hopefully I removed the evil although it may remain in the details. ComponentDescriptor is now much smaller and I removed all the code trying to eliminate duplicates.

@acabarbaye acabarbaye requested a review from muchzill4 February 25, 2020 14:03
@muchzill4 muchzill4 dismissed their stale review February 26, 2020 08:11

Just in case it blocks merges

@muchzill4
Copy link
Contributor

@acabarbaye I'm sorry, but I'm not willing to review this again. I still see things I'm unhappy about, but I don't find it productive to work against such big diff.

I think we should revisit the approach we take with regards to pull requests, especially that maintainability is part of our motto. ;)

@muchzill4 muchzill4 removed their request for review February 26, 2020 08:18
@acabarbaye acabarbaye merged commit a494c22 into master Feb 27, 2020
@acabarbaye acabarbaye deleted the windows branch February 27, 2020 16:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants