Skip to content

Commit

Permalink
chore: add deprecation of old classes
Browse files Browse the repository at this point in the history
  • Loading branch information
chemelli74 committed Oct 14, 2024
1 parent 0702859 commit 8e8612b
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion midealocal/message.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Midea local message."""

import logging
import warnings
from enum import IntEnum
from typing import Generic, SupportsIndex, TypeVar, cast
from typing import Any, Generic, SupportsIndex, TypeVar, cast

from midealocal.const import DeviceType

Expand Down Expand Up @@ -270,6 +271,32 @@ class ListTypes(IntEnum):
X9F = 0x9F


class BodyType(IntEnum):
"""Body Types (Deprecated)."""

@classmethod
def _missing_(cls, value: Any) -> IntEnum: # noqa: ANN401
warnings.warn(

Check warning on line 279 in midealocal/message.py

View check run for this annotation

Codecov / codecov/patch

midealocal/message.py#L279

Added line #L279 was not covered by tests
"BodyType is deprecated, use ListTypes instead.",
DeprecationWarning,
stacklevel=2,
)
return ListTypes(value)

Check warning on line 284 in midealocal/message.py

View check run for this annotation

Codecov / codecov/patch

midealocal/message.py#L284

Added line #L284 was not covered by tests


class SubBodyType(IntEnum):
"""SubBody Types (Deprecated)."""

@classmethod
def _missing_(cls, value: Any) -> IntEnum: # noqa: ANN401
warnings.warn(

Check warning on line 292 in midealocal/message.py

View check run for this annotation

Codecov / codecov/patch

midealocal/message.py#L292

Added line #L292 was not covered by tests
"SubBodyType is deprecated, use ListTypes instead.",
DeprecationWarning,
stacklevel=2,
)
return ListTypes(value)

Check warning on line 297 in midealocal/message.py

View check run for this annotation

Codecov / codecov/patch

midealocal/message.py#L297

Added line #L297 was not covered by tests


class MessageLenError(Exception):
"""Message length exception."""

Expand Down

0 comments on commit 8e8612b

Please sign in to comment.