diff --git a/fbchat/_core.py b/fbchat/_core.py index 3f03a4b..fed25af 100644 --- a/fbchat/_core.py +++ b/fbchat/_core.py @@ -1,7 +1,6 @@ import sys import attr import logging -import aenum log = logging.getLogger("fbchat") @@ -12,25 +11,6 @@ kw_only = sys.version_info[:2] > (3, 5) attrs_default = attr.s(slots=True, kw_only=kw_only) -class Enum(aenum.Enum): - """Used internally to support enumerations""" - - def __repr__(self): - # For documentation: - return "{}.{}".format(type(self).__name__, self.name) - - @classmethod - def _extend_if_invalid(cls, value): - try: - return cls(value) - except ValueError: - log.warning( - "Failed parsing {.__name__}({!r}). Extending enum.".format(cls, value) - ) - aenum.extend_enum(cls, "UNKNOWN_{}".format(value).upper(), value) - return cls(value) - - # Frozen, so that it can be used in sets @attr.s(frozen=True, slots=True, kw_only=kw_only) class Image: diff --git a/fbchat/_message.py b/fbchat/_message.py index f9807c7..6cefdc8 100644 --- a/fbchat/_message.py +++ b/fbchat/_message.py @@ -1,11 +1,12 @@ import attr +import enum from string import Formatter -from ._core import log, attrs_default, Enum +from ._core import log, attrs_default from . import _util, _session, _attachment, _location, _file, _quick_reply, _sticker from typing import Optional -class EmojiSize(Enum): +class EmojiSize(enum.Enum): """Used to specify the size of a sent emoji.""" LARGE = "369239383222810" diff --git a/fbchat/_plan.py b/fbchat/_plan.py index 9eff6ac..3cfbf89 100644 --- a/fbchat/_plan.py +++ b/fbchat/_plan.py @@ -1,10 +1,11 @@ import attr import datetime -from ._core import attrs_default, Enum +import enum +from ._core import attrs_default from . import _exception, _util, _session -class GuestStatus(Enum): +class GuestStatus(enum.Enum): INVITED = 1 GOING = 2 DECLINED = 3 diff --git a/fbchat/_thread.py b/fbchat/_thread.py index 990568c..628cb3e 100644 --- a/fbchat/_thread.py +++ b/fbchat/_thread.py @@ -2,12 +2,13 @@ import abc import attr import collections import datetime -from ._core import attrs_default, Enum, Image +import enum +from ._core import attrs_default, Image from . import _util, _exception, _session, _graphql, _attachment, _file, _plan from typing import MutableMapping, Any, Iterable, Tuple, Optional -class ThreadLocation(Enum): +class ThreadLocation(enum.Enum): """Used to specify where a thread is located (inbox, pending, archived, other).""" INBOX = "INBOX" diff --git a/pyproject.toml b/pyproject.toml index f586ea2..50c5ea0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,6 @@ maintainer = "Mads Marquart" maintainer-email = "madsmtm@gmail.com" home-page = "https://github.com/carpedm20/fbchat/" requires = [ - "aenum~=2.0", "attrs>=19.1", "requests~=2.19", "beautifulsoup4~=4.0", diff --git a/tests/test_core.py b/tests/test_core.py deleted file mode 100644 index a35404c..0000000 --- a/tests/test_core.py +++ /dev/null @@ -1,14 +0,0 @@ -import pytest -from fbchat._core import Enum - - -@pytest.mark.filterwarnings("ignore::DeprecationWarning") -def test_enum_extend_if_invalid(): - class TestEnum(Enum): - A = 1 - B = 2 - - assert TestEnum._extend_if_invalid(1) == TestEnum.A - assert TestEnum._extend_if_invalid(3) == TestEnum.UNKNOWN_3 - assert TestEnum._extend_if_invalid(3) == TestEnum.UNKNOWN_3 - assert TestEnum(3) == TestEnum.UNKNOWN_3