jetpytools 2.0.1__tar.gz → 2.0.2__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.1 → jetpytools-2.0.2}/PKG-INFO +1 -1
  2. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/_metadata.py +1 -1
  3. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/types/utils.py +35 -21
  4. {jetpytools-2.0.1 → jetpytools-2.0.2}/.gitignore +0 -0
  5. {jetpytools-2.0.1 → jetpytools-2.0.2}/LICENSE +0 -0
  6. {jetpytools-2.0.1 → jetpytools-2.0.2}/README.md +0 -0
  7. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/__init__.py +0 -0
  8. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/enums/__init__.py +0 -0
  9. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/enums/base.py +0 -0
  10. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/enums/other.py +0 -0
  11. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/exceptions/__init__.py +0 -0
  12. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/exceptions/base.py +0 -0
  13. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/exceptions/enum.py +0 -0
  14. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/exceptions/file.py +0 -0
  15. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/exceptions/generic.py +0 -0
  16. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/exceptions/module.py +0 -0
  17. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/functions/__init__.py +0 -0
  18. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/functions/funcs.py +0 -0
  19. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/functions/normalize.py +0 -0
  20. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/functions/other.py +0 -0
  21. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/py.typed +0 -0
  22. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/types/__init__.py +0 -0
  23. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/types/builtins.py +0 -0
  24. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/types/check.py +0 -0
  25. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/types/file.py +0 -0
  26. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/types/funcs.py +0 -0
  27. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/types/generic.py +0 -0
  28. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/types/supports.py +0 -0
  29. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/utils/__init__.py +0 -0
  30. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/utils/file.py +0 -0
  31. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/utils/funcs.py +0 -0
  32. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/utils/math.py +0 -0
  33. {jetpytools-2.0.1 → jetpytools-2.0.2}/jetpytools/utils/ranges.py +0 -0
  34. {jetpytools-2.0.1 → jetpytools-2.0.2}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jetpytools
3
- Version: 2.0.1
3
+ Version: 2.0.2
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.1"
3
+ __version__ = "2.0.2"
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__
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import sys
4
4
  from contextlib import suppress
5
5
  from functools import wraps
6
- from inspect import Signature
6
+ from inspect import Signature, get_annotations
7
7
  from typing import (
8
8
  TYPE_CHECKING,
9
9
  Any,
@@ -498,13 +498,13 @@ class inject_kwargs_params(_InjectKwargsParamsBase[_T_co, _P, _R_co]):
498
498
 
499
499
 
500
500
  class _ComplexHash[**P, R]:
501
- __slots__ = "func"
501
+ __slots__ = "_func"
502
502
 
503
503
  def __init__(self, func: Callable[P, R]) -> None:
504
- self.func = func
504
+ self._func = func
505
505
 
506
506
  def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
507
- return self.func(*args, **kwargs)
507
+ return self._func(*args, **kwargs)
508
508
 
509
509
  @staticmethod
510
510
  def hash(*args: Any) -> int:
@@ -515,8 +515,8 @@ class _ComplexHash[**P, R]:
515
515
 
516
516
  :return: Hash of all the combined objects' hashes.
517
517
  """
518
-
519
518
  values = list[str]()
519
+
520
520
  for value in args:
521
521
  try:
522
522
  new_hash = hash(value)
@@ -531,18 +531,21 @@ class _ComplexHash[**P, R]:
531
531
  @_ComplexHash
532
532
  def complex_hash[T](cls: type[T]) -> type[T]:
533
533
  """
534
- Decorator for classes to add a ``__hash__`` method to them.
534
+ Class decorator that automatically adds a ``__hash__`` method to the target class.
535
535
 
536
- Especially useful for NamedTuples.
536
+ The generated ``__hash__`` method computes a hash value derived from:
537
+ - the class's name
538
+ - the values of all attributes listed in its type annotations.
539
+
540
+ This is particularly useful for immutable data structures (e.g., NamedTuples or dataclasses).
537
541
  """
538
542
 
539
543
  def __hash__(self: T) -> int: # noqa: N807
540
- return complex_hash.hash(self.__class__.__name__, *(getattr(self, key) for key in self.__annotations__))
544
+ return complex_hash.hash(self.__class__.__name__, *(getattr(self, key) for key in get_annotations(cls)))
541
545
 
542
- ns = cls.__dict__.copy()
543
- ns["__hash__"] = __hash__
546
+ setattr(cls, __hash__.__name__, __hash__)
544
547
 
545
- return type(cls.__name__, (cls,), ns) # pyright: ignore[reportReturnType]
548
+ return cls
546
549
 
547
550
 
548
551
  def get_subclasses[T](family: type[T], exclude: Sequence[type[T]] = []) -> list[type[T]]:
@@ -794,22 +797,33 @@ class KwargsNotNone(KwargsT):
794
797
 
795
798
 
796
799
  class SingletonMeta(type):
797
- _instances: ClassVar[dict[type[Any], Any]] = {}
800
+ _instances: ClassVar[dict[SingletonMeta, Any]] = {}
798
801
  _singleton_init: bool
799
802
 
800
803
  def __new__[MetaSelf: SingletonMeta](
801
- mcls: type[MetaSelf], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any
804
+ mcls: type[MetaSelf],
805
+ name: str,
806
+ bases: tuple[type, ...],
807
+ namespace: dict[str, Any],
808
+ *,
809
+ init: bool = False,
810
+ **kwargs: Any,
802
811
  ) -> MetaSelf:
803
- namespace["_singleton_init"] = kwargs.pop("init", False)
804
- return super().__new__(mcls, name, bases, namespace, **kwargs)
812
+ cls = super().__new__(mcls, name, bases, namespace, **kwargs)
813
+ cls._singleton_init = init
814
+ return cls
815
+
816
+ if not TYPE_CHECKING:
817
+
818
+ def __call__(cls, *args: Any, **kwargs: Any) -> Any:
819
+ if cls not in cls._instances:
820
+ cls._instances[cls] = obj = super().__call__(*args, **kwargs)
821
+ return obj
805
822
 
806
- def __call__(cls, *args: Any, **kwargs: Any) -> SingletonMeta:
807
- if cls not in cls._instances:
808
- cls._instances[cls] = super(SingletonMeta, cls).__call__(*args, **kwargs)
809
- elif cls._singleton_init:
810
- cls._instances[cls].__init__(*args, **kwargs)
823
+ if cls._singleton_init:
824
+ cls._instances[cls].__init__(*args, **kwargs)
811
825
 
812
- return cls._instances[cls]
826
+ return cls._instances[cls]
813
827
 
814
828
 
815
829
  class Singleton(metaclass=SingletonMeta):
File without changes
File without changes
File without changes
File without changes