jetpytools 2.0.2__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of jetpytools might be problematic. Click here for more details.

Files changed (34) hide show
  1. {jetpytools-2.0.2 → jetpytools-2.1.0}/PKG-INFO +1 -1
  2. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/_metadata.py +1 -1
  3. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/enums/base.py +19 -25
  4. {jetpytools-2.0.2 → jetpytools-2.1.0}/.gitignore +0 -0
  5. {jetpytools-2.0.2 → jetpytools-2.1.0}/LICENSE +0 -0
  6. {jetpytools-2.0.2 → jetpytools-2.1.0}/README.md +0 -0
  7. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/__init__.py +0 -0
  8. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/enums/__init__.py +0 -0
  9. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/enums/other.py +0 -0
  10. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/exceptions/__init__.py +0 -0
  11. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/exceptions/base.py +0 -0
  12. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/exceptions/enum.py +0 -0
  13. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/exceptions/file.py +0 -0
  14. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/exceptions/generic.py +0 -0
  15. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/exceptions/module.py +0 -0
  16. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/functions/__init__.py +0 -0
  17. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/functions/funcs.py +0 -0
  18. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/functions/normalize.py +0 -0
  19. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/functions/other.py +0 -0
  20. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/py.typed +0 -0
  21. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/types/__init__.py +0 -0
  22. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/types/builtins.py +0 -0
  23. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/types/check.py +0 -0
  24. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/types/file.py +0 -0
  25. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/types/funcs.py +0 -0
  26. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/types/generic.py +0 -0
  27. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/types/supports.py +0 -0
  28. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/types/utils.py +0 -0
  29. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/utils/__init__.py +0 -0
  30. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/utils/file.py +0 -0
  31. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/utils/funcs.py +0 -0
  32. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/utils/math.py +0 -0
  33. {jetpytools-2.0.2 → jetpytools-2.1.0}/jetpytools/utils/ranges.py +0 -0
  34. {jetpytools-2.0.2 → jetpytools-2.1.0}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jetpytools
3
- Version: 2.0.2
3
+ Version: 2.1.0
4
4
  Summary: Collection of stuff that's useful in general python programming
5
5
  Project-URL: Source Code, https://github.com/Jaded-Encoding-Thaumaturgy/jetpytools
6
6
  Project-URL: Contact, https://discord.gg/XTpc6Fa9eB
@@ -1,6 +1,6 @@
1
1
  """Collection of stuff that's useful in general python programming"""
2
2
 
3
- __version__ = "2.0.2"
3
+ __version__ = "2.1.0"
4
4
 
5
5
  __author_name__, __author_email__ = "Jaded Encoding Thaumaturgy", "jaded.encoding.thaumaturgy@gmail.com"
6
6
  __maintainer_name__, __maintainer_email__ = __author_name__, __author_email__
@@ -1,23 +1,24 @@
1
1
  from __future__ import annotations
2
2
 
3
- from enum import Enum
3
+ from abc import ABCMeta
4
+ from enum import Enum, EnumMeta
4
5
  from typing import Any, Self
5
6
 
6
- from ..exceptions import CustomValueError, NotFoundEnumValue
7
+ from ..exceptions import NotFoundEnumValueError
7
8
  from ..types import FuncExcept
8
9
 
9
- __all__ = ["CustomEnum", "CustomIntEnum", "CustomStrEnum"]
10
+ __all__ = ["CustomEnum", "CustomIntEnum", "CustomStrEnum", "EnumABCMeta"]
11
+
12
+
13
+ class EnumABCMeta(EnumMeta, ABCMeta):
14
+ """Metaclass combining EnumMeta and ABCMeta to support abstract enumerations."""
10
15
 
11
16
 
12
17
  class CustomEnum(Enum):
13
18
  """Base class for custom enums."""
14
19
 
15
20
  @classmethod
16
- def _missing_(cls, value: Any) -> Self | None:
17
- return cls.from_param(value)
18
-
19
- @classmethod
20
- def from_param(cls, value: Any, func_except: FuncExcept | None = None) -> Self | None:
21
+ def from_param(cls, value: Any, func_except: FuncExcept | None = None) -> Self:
21
22
  """
22
23
  Return the enum value from a parameter.
23
24
 
@@ -28,44 +29,37 @@ class CustomEnum(Enum):
28
29
 
29
30
  :raises NotFoundEnumValue: Variable not found in the given enum.
30
31
  """
31
-
32
- if value is None:
33
- return None
34
-
35
- if func_except is None:
36
- func_except = cls.from_param
37
-
38
- if isinstance(value, cls):
39
- return value
40
-
41
- if value is cls:
42
- raise CustomValueError("You must select a member, not pass the enum!", func_except)
32
+ func_except = func_except or cls.from_param
43
33
 
44
34
  try:
45
35
  return cls(value)
46
- except Exception:
36
+ except (ValueError, TypeError):
47
37
  pass
48
38
 
49
39
  if isinstance(func_except, tuple):
50
40
  func_name, var_name = func_except
51
41
  else:
52
- func_name, var_name = func_except, str(cls)
42
+ func_name, var_name = func_except, repr(cls)
53
43
 
54
- raise NotFoundEnumValue(
44
+ raise NotFoundEnumValueError(
55
45
  'The given value for "{var_name}" argument must be a valid {enum_name}, not "{value}"!\n'
56
46
  "Valid values are: [{readable_enum}].",
57
47
  func_name,
58
48
  var_name=var_name,
59
49
  enum_name=cls,
60
50
  value=value,
61
- readable_enum=iter([f"{x.name} ({x.value})" for x in cls]),
51
+ readable_enum=(f"{name} ({value!r})" for name, value in cls.__members__.items()),
62
52
  reason=value,
63
- )
53
+ ) from None
64
54
 
65
55
 
66
56
  class CustomIntEnum(int, CustomEnum):
67
57
  """Base class for custom int enums."""
68
58
 
59
+ _value_: int
60
+
69
61
 
70
62
  class CustomStrEnum(str, CustomEnum):
71
63
  """Base class for custom str enums."""
64
+
65
+ _value_: str
File without changes
File without changes
File without changes
File without changes