jetpytools 1.3.0__py3-none-any.whl → 1.4.0__py3-none-any.whl

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.

jetpytools/_metadata.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Collection of stuff that's useful in general python programming"""
2
2
 
3
- __version__ = '1.3.0'
3
+ __version__ = '1.4.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__
@@ -72,10 +72,6 @@ class CustomErrorMeta(type):
72
72
 
73
73
  return exception
74
74
 
75
- if TYPE_CHECKING:
76
- def __getitem__(self, exception: type[Exception]) -> CustomError:
77
- ...
78
-
79
75
 
80
76
  SelfCErrorMeta = TypeVar('SelfCErrorMeta', bound=CustomErrorMeta)
81
77
 
@@ -102,17 +98,11 @@ class CustomError(ExceptionT, metaclass=CustomErrorMeta):
102
98
  super().__init__(message)
103
99
 
104
100
  def __class_getitem__(cls, exception: str | type[ExceptionT] | ExceptionT) -> CustomError:
105
- if isinstance(exception, str):
106
- class inner_exception(cls): # type: ignore
107
- ...
108
- else:
109
- if not issubclass(exception, type): # type: ignore
110
- exception = exception.__class__ # type: ignore
101
+ from warnings import warn
111
102
 
112
- class inner_exception(cls, exception): # type: ignore
113
- ...
103
+ warn("Custom error is not subscriptable anymore. Don't use it", DeprecationWarning)
114
104
 
115
- return CustomErrorMeta.setup_exception(inner_exception, exception) # type: ignore
105
+ return cls()
116
106
 
117
107
  def __call__(
118
108
  self,
jetpytools/types/utils.py CHANGED
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  from functools import partial, wraps
4
4
  from inspect import Signature
5
5
  from inspect import _empty as empty_param
6
- from inspect import isclass
7
6
  from typing import (
8
7
  TYPE_CHECKING, Any, Callable, Concatenate, Generator, Generic, Iterable, Iterator, Mapping, NoReturn, Protocol,
9
8
  Sequence, TypeVar, cast, overload
@@ -411,89 +410,55 @@ def get_subclasses(family: type[T], exclude: Sequence[type[T]] = []) -> list[typ
411
410
  return list(set(_subclasses(family)))
412
411
 
413
412
 
414
- class classproperty(Generic[P, R, T, T0, P0]):
413
+ class classproperty(Generic[T, R]):
415
414
  """
416
415
  Make a class property. A combination between classmethod and property.
417
416
  """
418
417
 
419
418
  __isabstractmethod__: bool = False
420
419
 
421
- class metaclass(type):
422
- """This must be set for the decorator to work."""
423
-
424
- def __setattr__(self, key: str, value: Any) -> None:
425
- if key in self.__dict__:
426
- obj = self.__dict__.get(key)
427
-
428
- if obj and isinstance(obj, classproperty):
429
- obj.__set__(self, value)
430
- return
431
-
432
- super(classproperty.metaclass, self).__setattr__(key, value)
433
-
434
420
  def __init__(
435
421
  self,
436
- fget: classmethod[T, P, R] | Callable[P, R],
437
- fset: classmethod[T, P, None] | Callable[[T, T0], None] | None = None,
438
- fdel: classmethod[T, P1, None] | Callable[P1, None] | None = None,
422
+ fget: Callable[[type[T]], R] | classmethod[T, ..., R],
423
+ fset: Callable[[type[T], R], None] | classmethod[T, Concatenate[R, ...], None] | None = None,
424
+ fdel: Callable[[type[T]], None] | classmethod[T, ..., None] | None = None,
439
425
  doc: str | None = None,
440
426
  ) -> None:
441
427
  self.fget = self._wrap(fget)
442
428
  self.fset = self._wrap(fset) if fset is not None else fset
443
429
  self.fdel = self._wrap(fdel) if fdel is not None else fdel
444
430
 
445
- self.doc = doc
431
+ self.__doc__ = doc
446
432
 
447
- def _wrap(self, func: classmethod[T1, P1, R1] | Callable[P1, R1] | Callable[..., R1]) -> classmethod[T1, P1, R1]:
448
- if not isinstance(func, (classmethod, staticmethod)):
449
- func = classmethod(func) # type: ignore
433
+ def _wrap(self, func: Callable[..., R1] | classmethod[T, P1, R1]) -> classmethod[T, P1, R1]:
434
+ if not isinstance(func, classmethod):
435
+ func = classmethod(func)
450
436
 
451
- return func # type: ignore
437
+ return func
452
438
 
453
- def getter(self, __fget: classmethod[T, P, R] | Callable[P1, R1]) -> classproperty[P1, R1, T, T0, P0]:
454
- self.fget = self._wrap(__fget) # type: ignore
455
- return self # type: ignore
456
-
457
- def setter(self, __fset: classmethod[T1, P, None] | Callable[[T1, T2], None]) -> classproperty[P, R, T1, T2, P0]:
458
- self.fset = self._wrap(__fset) # type: ignore
459
- return self # type: ignore
460
-
461
- def deleter(self, __fdel: classmethod[T1, P1, None] | Callable[P1, None]) -> classproperty[P, R, T, T0, P1]:
462
- self.fdel = self._wrap(__fdel) # type: ignore
463
- return self # type: ignore
464
-
465
- def __get__(self, __obj: Any, __type: type | None = None) -> R:
439
+ def __get__(self, __obj: T | None, __type: type | None = None) -> R:
466
440
  if __type is None:
467
441
  __type = type(__obj)
468
442
 
469
- return self.fget.__get__(__obj, __type)() # type: ignore
470
-
471
- def __set__(self, __obj: Any, __value: Any) -> None:
472
- from ..exceptions import CustomError
443
+ return self.fget.__get__(__obj, __type)()
473
444
 
445
+ def __set__(self, __obj: T, __value: Any) -> None:
474
446
  if not self.fset:
475
- raise CustomError[AttributeError]("Can't set attribute")
476
-
477
- if isclass(__obj):
478
- type_, __obj = __obj, None
479
- else:
480
- type_ = type(__obj)
481
-
482
- return self.fset.__get__(__obj, type_)(__value) # type: ignore[call-arg]
447
+ raise AttributeError(
448
+ f'classproperty with getter "{self.__name__}" of "{__obj.__class__.__name__}" object has no setter.'
449
+ )
483
450
 
484
- def __delete__(self, __obj: Any) -> None:
485
- from ..exceptions import CustomError
451
+ self.fset.__get__(None, type(__obj))(__value)
486
452
 
453
+ def __delete__(self, __obj: T) -> None:
487
454
  if not self.fdel:
488
- raise CustomError[AttributeError]("Can't delete attribute")
489
-
490
- if isclass(__obj):
491
- type_, __obj = __obj, None
492
- else:
493
- type_ = type(__obj)
455
+ raise AttributeError(
456
+ f'classproperty with getter "{self.__name__}" of "{__obj.__class__.__name__}" object has no deleter.'
457
+ )
494
458
 
495
- return self.fdel.__delete__(__obj, type_)(__obj) # type: ignore
459
+ self.fdel.__get__(None, type(__obj))()
496
460
 
461
+ @property
497
462
  def __name__(self) -> str:
498
463
  return self.fget.__name__
499
464
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jetpytools
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Collection of stuff that's useful in general python programming
5
5
  Author: Jaded Encoding Thaumaturgy
6
6
  Author-email: jaded.encoding.thaumaturgy@gmail.com
@@ -1,11 +1,11 @@
1
1
  jetpytools/__init__.py,sha256=FSVZdj69oy4mBXd6OXiRHrUhaSc4Exo1pQHBlXycV98,214
2
- jetpytools/_metadata.py,sha256=eS1eELVPfezPGbsmiPMEm5oNHOldKdKzoADAs3a7GfI,414
2
+ jetpytools/_metadata.py,sha256=v1lmWTzb06HMM9cWuvZNc6UWkUsfNUm_rmuwcgdFavs,414
3
3
  jetpytools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  jetpytools/enums/__init__.py,sha256=5n6Cu8Yb9N6hIa_YTsyy_s0cCgCnh0vDb-NyXK2RwV0,81
5
5
  jetpytools/enums/base.py,sha256=m3jJ6rJwDm4vp2-qMsuRH-Ll2mQDXA-wkmhw4xaafTM,2003
6
6
  jetpytools/enums/other.py,sha256=DerFtmdjNK41ZxSYt601vHV5yzvZHPfTKNDlj-FjHm8,1346
7
7
  jetpytools/exceptions/__init__.py,sha256=g8GT0XqcNuHFHgQGSRj6a_X1kBiBQGP05soYNbEIN_Q,205
8
- jetpytools/exceptions/base.py,sha256=ESwC7H8iCQW9DGMGmaoFwIiid98tE1e6sATjOH_7Duc,6370
8
+ jetpytools/exceptions/base.py,sha256=OZS5sJlNCh4Qy-2flvZugYpyJuXoRrxXa7RFqdDAktw,5969
9
9
  jetpytools/exceptions/enum.py,sha256=9YoWwEfyd9k7NwanAqtXbhJaJQAnjRKqsAO73cDvcpA,223
10
10
  jetpytools/exceptions/file.py,sha256=QwhUFAoG3NsFFYuPe5O_I6K969CzlrTCv3RTrfzx8B0,1107
11
11
  jetpytools/exceptions/generic.py,sha256=kMj5lR3ifHk3uNhpxN6Lu4Am0vi7E6TfQezkZulqhaQ,1482
@@ -21,14 +21,14 @@ jetpytools/types/file.py,sha256=j46SCbdhus2wtxddAGSCn6V4nJdWWwpnAfW1K3P3ewg,6205
21
21
  jetpytools/types/funcs.py,sha256=9qONnDWdpqvRj7vL3W9BLwWeGyQipXQgxOaPjqpQ1M4,3119
22
22
  jetpytools/types/generic.py,sha256=sAyBwGVG5FZ-6HVpfRuczov_6zQ_Uyoi0QWnR2iMm9Q,1128
23
23
  jetpytools/types/supports.py,sha256=--VZ-iCUiv-a6K8n-H8-6hSxHjrvdYg9mCLhr_lRplo,3051
24
- jetpytools/types/utils.py,sha256=g4koJlZADtjlghb-lwr8yLKZseHb3ewr9zPRVV6gY6Y,22326
24
+ jetpytools/types/utils.py,sha256=eT3yoFUEQy4vKTyLDMp_6Ixy7woyF4afWgiLhS-Vr38,21030
25
25
  jetpytools/utils/__init__.py,sha256=v5Bkl43-OBWlXx9OWpZoGH-QMaYNsPIi4vfuhC13ZLI,163
26
26
  jetpytools/utils/file.py,sha256=9GhMGJ5D7CpvUFnvnwPFMloYTeIX-AJ7aKYKdoJQ374,10455
27
27
  jetpytools/utils/funcs.py,sha256=ZuLz63kveBY1CLlBexEqmrQiGC67dY4gaXdNU3CeBMw,898
28
28
  jetpytools/utils/math.py,sha256=lNTriLtTXgqN82DVSXJ5KUbhsWgxXoJ5eNGIZ0-_r_c,3335
29
29
  jetpytools/utils/ranges.py,sha256=dL3WG235Pz9sk5su8A0VdwVf_oSt6obR7R_JNwLyCjQ,2572
30
- jetpytools-1.3.0.dist-info/licenses/LICENSE,sha256=l0PN-qDtXcgOB5aXP_nSUsvCK5V3o9pQCGsTzyZhKL0,1071
31
- jetpytools-1.3.0.dist-info/METADATA,sha256=YRcJlTBXMHdJFLjuq4sDZPpRtVkawZabK03TE8v0T5c,1485
32
- jetpytools-1.3.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
33
- jetpytools-1.3.0.dist-info/top_level.txt,sha256=Iy4HjIta33ADJxN9Nyt5t5jRIfotEkZkQcOSw4eG8Cs,11
34
- jetpytools-1.3.0.dist-info/RECORD,,
30
+ jetpytools-1.4.0.dist-info/licenses/LICENSE,sha256=l0PN-qDtXcgOB5aXP_nSUsvCK5V3o9pQCGsTzyZhKL0,1071
31
+ jetpytools-1.4.0.dist-info/METADATA,sha256=vNcju4cgq0KyWoml7dd6q6QWq8KCvUIQT-DciIXtYe8,1485
32
+ jetpytools-1.4.0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
33
+ jetpytools-1.4.0.dist-info/top_level.txt,sha256=Iy4HjIta33ADJxN9Nyt5t5jRIfotEkZkQcOSw4eG8Cs,11
34
+ jetpytools-1.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5