Skip to content

Commit

Permalink
Mark device_classes inside devicegroupmeta as private (#1129)
Browse files Browse the repository at this point in the history
* mark device_classes inside devicegroupmeta as private

* Define device_classes as class method

* Remove the unnecessary property getter, the inheriting classes should not access this anyway
  • Loading branch information
rytilahti authored Sep 2, 2021
1 parent 0adc235 commit fc47803
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion miio/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def cli(ctx, debug: int, output: str):
ctx.obj = GlobalContextObject(debug=debug, output=output_func)


for device_class in DeviceGroupMeta.device_classes:
for device_class in DeviceGroupMeta._device_classes:
cli.add_command(device_class.get_device_group())


Expand Down
4 changes: 2 additions & 2 deletions miio/click_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(self, debug: int = 0, output: Callable = None):

class DeviceGroupMeta(type):

device_classes: Set[Type] = set()
_device_classes: Set[Type] = set()

def __new__(mcs, name, bases, namespace):
commands = {}
Expand Down Expand Up @@ -150,7 +150,7 @@ def get_device_group(dcls):
namespace["get_device_group"] = classmethod(get_device_group)

cls = super().__new__(mcs, name, bases, namespace)
mcs.device_classes.add(cls)
mcs._device_classes.add(cls)
return cls


Expand Down

0 comments on commit fc47803

Please sign in to comment.