Skip to content

Commit

Permalink
Fix and standardize abstractmethod use
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Oct 25, 2024
1 parent 5ee14dd commit 3898935
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion circuitmatter/device_types/lighting/dimmable.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ def brightness(self):
return self._level_control.CurrentLevel / self._level_control.max_level

@brightness.setter
@abstractmethod
@abc.abstractmethod
def brightness(self, value):
raise NotImplementedError()
6 changes: 3 additions & 3 deletions circuitmatter/device_types/lighting/on_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

from abc import abstractmethod
import abc

from circuitmatter.clusters.general import on_off
from circuitmatter.clusters.general.identify import Identify
Expand Down Expand Up @@ -44,12 +44,12 @@ def _off(self, session):
return
self._on_off.OnOff = False

@abstractmethod
@abc.abstractmethod
def on(self):
"""Called when the light is turned on"""
pass

@abstractmethod
@abc.abstractmethod
def off(self):
"""Called when the light is turned off"""
pass
16 changes: 8 additions & 8 deletions circuitmatter/tlv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from __future__ import annotations

import abc
import enum
import math
import struct
from abc import ABC, abstractmethod
from collections.abc import Iterable
from typing import (
AnyStr,
Expand Down Expand Up @@ -208,7 +208,7 @@ def from_value(cls, value):
_OPT = TypeVar("_OPT", Literal[True], Literal[False])


class Member(ABC, Generic[_T, _OPT, _NULLABLE]):
class Member(abc.ABC, Generic[_T, _OPT, _NULLABLE]):
max_value_length: int = 0

def __init__(
Expand Down Expand Up @@ -356,39 +356,39 @@ def decode(self, buffer: memoryview, offset: int = 0) -> _T:
"""Return the decoded value at ``offset`` in ``buffer``"""
return self.decode_member(buffer[offset], buffer, offset + 1)[0]

@abstractmethod
@abc.abstractmethod
def decode_member(self, control_octet: int, buffer: memoryview, offset: int = 0) -> (_T, int):
"""Return the decoded value at ``offset`` in ``buffer``. ``offset`` is after the tag
(but before any length)"""
...

@abstractmethod
@abc.abstractmethod
def encode_element_type(self, value: _T) -> int:
"""Return Element Type Field as defined in Appendix A in the spec"""
...

@overload
@abstractmethod
@abc.abstractmethod
def encode_value_into(
self: Member[_T, Literal[True], _NULLABLE] | Member[_T, _OPT, Literal[True]],
value: _T | None,
buffer: bytearray,
offset: int,
) -> int: ...
@overload
@abstractmethod
@abc.abstractmethod
def encode_value_into(
self: Member[_T, Literal[False], Literal[False]],
value: _T,
buffer: bytearray,
offset: int,
) -> int: ...
@abstractmethod
@abc.abstractmethod
def encode_value_into(self, value: _T | None, buffer: bytearray, offset: int) -> int:
"""Encode ``value`` into ``buffer`` and return the new offset"""
...

@abstractmethod
@abc.abstractmethod
def print(self, value: _T) -> str:
"""Return string representation of ``value``"""
...
Expand Down

0 comments on commit 3898935

Please sign in to comment.