jetpytools 1.7.3__py3-none-any.whl → 1.7.4__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 +1 -1
- jetpytools/types/utils.py +39 -32
- {jetpytools-1.7.3.dist-info → jetpytools-1.7.4.dist-info}/METADATA +1 -1
- {jetpytools-1.7.3.dist-info → jetpytools-1.7.4.dist-info}/RECORD +6 -6
- {jetpytools-1.7.3.dist-info → jetpytools-1.7.4.dist-info}/WHEEL +0 -0
- {jetpytools-1.7.3.dist-info → jetpytools-1.7.4.dist-info}/licenses/LICENSE +0 -0
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.7.
|
|
3
|
+
__version__ = "1.7.4"
|
|
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__
|
jetpytools/types/utils.py
CHANGED
|
@@ -25,7 +25,7 @@ from typing import (
|
|
|
25
25
|
|
|
26
26
|
from typing_extensions import Self, TypeVar, deprecated
|
|
27
27
|
|
|
28
|
-
from .builtins import F0, F1, P0, P1, R0,
|
|
28
|
+
from .builtins import F0, F1, P0, P1, R0, T0, KwargsT, P, R, R0_co, R1_co, R_co, T, T0_co, T1_co, T_co
|
|
29
29
|
|
|
30
30
|
__all__ = [
|
|
31
31
|
"KwargsNotNone",
|
|
@@ -401,35 +401,37 @@ def get_subclasses(family: type[T], exclude: Sequence[type[T]] = []) -> list[typ
|
|
|
401
401
|
return list(set(_subclasses(family)))
|
|
402
402
|
|
|
403
403
|
|
|
404
|
-
|
|
404
|
+
_T_Any = TypeVar("_T_Any", default=Any)
|
|
405
|
+
_T0_Any = TypeVar("_T0_Any", default=Any)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
class classproperty_base(Generic[T, R_co, _T_Any]):
|
|
405
409
|
__isabstractmethod__: bool = False
|
|
406
410
|
|
|
411
|
+
fget: Callable[[type[T]], R_co]
|
|
412
|
+
fset: Callable[Concatenate[type[T], _T_Any, ...], None] | None
|
|
413
|
+
fdel: Callable[[type[T]], None] | None
|
|
414
|
+
|
|
407
415
|
def __init__(
|
|
408
416
|
self,
|
|
409
417
|
fget: Callable[[type[T]], R_co] | classmethod[T, ..., R_co],
|
|
410
|
-
fset: Callable[Concatenate[type[T],
|
|
411
|
-
| classmethod[T, Concatenate[
|
|
418
|
+
fset: Callable[Concatenate[type[T], _T_Any, ...], None]
|
|
419
|
+
| classmethod[T, Concatenate[_T_Any, ...], None]
|
|
412
420
|
| None = None,
|
|
413
421
|
fdel: Callable[[type[T]], None] | classmethod[T, ..., None] | None = None,
|
|
414
422
|
doc: str | None = None,
|
|
415
423
|
) -> None:
|
|
416
|
-
self.fget =
|
|
417
|
-
self.fset =
|
|
418
|
-
self.fdel =
|
|
424
|
+
self.fget = fget.__func__ if isinstance(fget, classmethod) else fget
|
|
425
|
+
self.fset = fset.__func__ if isinstance(fset, classmethod) else fset
|
|
426
|
+
self.fdel = fdel.__func__ if isinstance(fdel, classmethod) else fdel
|
|
419
427
|
|
|
420
428
|
self.__doc__ = doc
|
|
421
429
|
self.__name__ = self.fget.__name__
|
|
422
430
|
|
|
423
|
-
def _wrap(self, func: Callable[..., R1] | classmethod[T, P1, R1]) -> classmethod[T, P1, R1]:
|
|
424
|
-
if not isinstance(func, classmethod):
|
|
425
|
-
func = classmethod(func)
|
|
426
|
-
|
|
427
|
-
return func
|
|
428
|
-
|
|
429
431
|
def __set_name__(self, owner: object, name: str) -> None:
|
|
430
432
|
self.__name__ = name
|
|
431
433
|
|
|
432
|
-
def _get_cache(self, type_: type) -> dict[str, Any]:
|
|
434
|
+
def _get_cache(self, type_: type[T]) -> dict[str, Any]:
|
|
433
435
|
cache_key = getattr(self, "cache_key")
|
|
434
436
|
|
|
435
437
|
if not hasattr(type_, cache_key):
|
|
@@ -437,21 +439,23 @@ class classproperty_base(Generic[T, R_co]):
|
|
|
437
439
|
|
|
438
440
|
return getattr(type_, cache_key)
|
|
439
441
|
|
|
440
|
-
def __get__(self, obj: T | None, type_: type | None = None) -> R_co:
|
|
441
|
-
if type_ is None:
|
|
442
|
+
def __get__(self, obj: T | None, type_: type[T] | None = None) -> R_co:
|
|
443
|
+
if type_ is None and obj is not None:
|
|
442
444
|
type_ = type(obj)
|
|
445
|
+
elif type_ is None:
|
|
446
|
+
raise NotImplementedError("Both obj and type_ are None")
|
|
443
447
|
|
|
444
448
|
if not isinstance(self, classproperty.cached):
|
|
445
|
-
return self.fget
|
|
449
|
+
return self.fget(type_)
|
|
446
450
|
|
|
447
451
|
if self.__name__ in (cache := self._get_cache(type_)):
|
|
448
452
|
return cache[self.__name__]
|
|
449
453
|
|
|
450
|
-
value = self.fget
|
|
454
|
+
value = self.fget(type_)
|
|
451
455
|
cache[self.__name__] = value
|
|
452
456
|
return value
|
|
453
457
|
|
|
454
|
-
def __set__(self, obj: T, value:
|
|
458
|
+
def __set__(self, obj: T, value: _T_Any) -> None:
|
|
455
459
|
if not self.fset:
|
|
456
460
|
raise AttributeError(
|
|
457
461
|
f'classproperty with getter "{self.__name__}" of "{obj.__class__.__name__}" object has no setter.'
|
|
@@ -459,10 +463,13 @@ class classproperty_base(Generic[T, R_co]):
|
|
|
459
463
|
|
|
460
464
|
type_ = type(obj)
|
|
461
465
|
|
|
466
|
+
if not isinstance(self, classproperty.cached):
|
|
467
|
+
return self.fset(type_, value)
|
|
468
|
+
|
|
462
469
|
if self.__name__ in (cache := self._get_cache(type_)):
|
|
463
470
|
del cache[self.__name__]
|
|
464
471
|
|
|
465
|
-
self.fset
|
|
472
|
+
self.fset(type_, value)
|
|
466
473
|
|
|
467
474
|
def __delete__(self, obj: T) -> None:
|
|
468
475
|
if not self.fdel:
|
|
@@ -472,18 +479,21 @@ class classproperty_base(Generic[T, R_co]):
|
|
|
472
479
|
|
|
473
480
|
type_ = type(obj)
|
|
474
481
|
|
|
482
|
+
if not isinstance(self, classproperty.cached):
|
|
483
|
+
return self.fdel(type_)
|
|
484
|
+
|
|
475
485
|
if self.__name__ in (cache := self._get_cache(type_)):
|
|
476
486
|
del cache[self.__name__]
|
|
477
487
|
|
|
478
|
-
self.fdel
|
|
488
|
+
self.fdel(type_)
|
|
479
489
|
|
|
480
490
|
|
|
481
|
-
class classproperty(classproperty_base[T, R_co]):
|
|
491
|
+
class classproperty(classproperty_base[T, R_co, _T_Any]):
|
|
482
492
|
"""
|
|
483
493
|
A combination of `classmethod` and `property`.
|
|
484
494
|
"""
|
|
485
495
|
|
|
486
|
-
class cached(classproperty_base[T0, R0_co]):
|
|
496
|
+
class cached(classproperty_base[T0, R0_co, _T0_Any]):
|
|
487
497
|
"""
|
|
488
498
|
A combination of `classmethod` and `property`.
|
|
489
499
|
|
|
@@ -516,10 +526,7 @@ class classproperty(classproperty_base[T, R_co]):
|
|
|
516
526
|
del cache[name]
|
|
517
527
|
|
|
518
528
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
class cachedproperty(property, Generic[R_co, _T_cc]):
|
|
529
|
+
class cachedproperty(property, Generic[R_co, _T_Any]):
|
|
523
530
|
"""
|
|
524
531
|
Wrapper for a one-time get property, that will be cached.
|
|
525
532
|
|
|
@@ -541,16 +548,16 @@ class cachedproperty(property, Generic[R_co, _T_cc]):
|
|
|
541
548
|
def __init__(
|
|
542
549
|
self,
|
|
543
550
|
fget: Callable[[Any], R_co],
|
|
544
|
-
fset: Callable[[Any,
|
|
551
|
+
fset: Callable[[Any, _T_Any], None] | None = None,
|
|
545
552
|
fdel: Callable[[Any], None] | None = None,
|
|
546
553
|
doc: str | None = None,
|
|
547
554
|
) -> None: ...
|
|
548
555
|
|
|
549
|
-
def getter(self, fget: Callable[..., R_co]) -> cachedproperty[R_co,
|
|
556
|
+
def getter(self, fget: Callable[..., R_co]) -> cachedproperty[R_co, _T_Any]: ...
|
|
550
557
|
|
|
551
|
-
def setter(self, fset: Callable[[Any,
|
|
558
|
+
def setter(self, fset: Callable[[Any, _T_Any], None]) -> cachedproperty[R_co, _T_Any]: ...
|
|
552
559
|
|
|
553
|
-
def deleter(self, fdel: Callable[..., None]) -> cachedproperty[R_co,
|
|
560
|
+
def deleter(self, fdel: Callable[..., None]) -> cachedproperty[R_co, _T_Any]: ...
|
|
554
561
|
|
|
555
562
|
if sys.version_info < (3, 13):
|
|
556
563
|
|
|
@@ -575,7 +582,7 @@ class cachedproperty(property, Generic[R_co, _T_cc]):
|
|
|
575
582
|
cache[self.__name__] = value
|
|
576
583
|
return value
|
|
577
584
|
|
|
578
|
-
def __set__(self, instance: Any, value:
|
|
585
|
+
def __set__(self, instance: Any, value: _T_Any) -> None:
|
|
579
586
|
if self.__name__ in (cache := instance.__dict__.setdefault(self.cache_key, {})):
|
|
580
587
|
del cache[self.__name__]
|
|
581
588
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jetpytools
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.4
|
|
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,5 +1,5 @@
|
|
|
1
1
|
jetpytools/__init__.py,sha256=ha_pCOMqfeIbipDRrtqKOqH3NQEpX4KwN2SskpsCGb4,114
|
|
2
|
-
jetpytools/_metadata.py,sha256=
|
|
2
|
+
jetpytools/_metadata.py,sha256=Ctf45XxZkSp6UiAUvlc0xW27P8V4tEMiFFSZtpGLKxA,414
|
|
3
3
|
jetpytools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
jetpytools/enums/__init__.py,sha256=TvEt3TWmnzf2TWS_Gd6llyyXAGDKxdhdJsDgSvT7xys,41
|
|
5
5
|
jetpytools/enums/base.py,sha256=s5A9iQS22JdaZMM6jEXI31m0ZjtBx7GLQ-E0xBr90Zc,2032
|
|
@@ -21,13 +21,13 @@ jetpytools/types/file.py,sha256=LbOwMAwDALWxAZZ2i7ZNexoN3GHWD-uUoIhVvUy95Vo,6539
|
|
|
21
21
|
jetpytools/types/funcs.py,sha256=U5tBmTtLS5CLp3ZtOiA5101PQiCWQOBsmf0bj1pRwgY,2778
|
|
22
22
|
jetpytools/types/generic.py,sha256=RRg2U7wxaM4Uzwc6QvsO99euCF3sqr8Kh34XKtVbgT8,1136
|
|
23
23
|
jetpytools/types/supports.py,sha256=woMTv62HpcRiC5TG18U8NU5v2Q6iqcrHzQgXl7QYEws,3516
|
|
24
|
-
jetpytools/types/utils.py,sha256=
|
|
24
|
+
jetpytools/types/utils.py,sha256=2E7eNZjwlkQIL-9KC7xj7nMULTHoivrUI22rdzPRw88,23651
|
|
25
25
|
jetpytools/utils/__init__.py,sha256=_rJ-mY5PsGjBfy8Fihx_FYJfAIGSrYAYzI6Td9oFh9A,83
|
|
26
26
|
jetpytools/utils/file.py,sha256=3fJxAHjIN5zdyzO0guc3jDspcs5HPG4t4cwB_ZrAhh4,10622
|
|
27
27
|
jetpytools/utils/funcs.py,sha256=2qhFyLD0OLvenjzOu2wu1ZWoZGzQ8aPmvbkAI1i9Gvk,914
|
|
28
28
|
jetpytools/utils/math.py,sha256=I56OeHDDJl3X8EFXMWVEiXGAD16AKcn8KVnFuP5fFes,3445
|
|
29
29
|
jetpytools/utils/ranges.py,sha256=glxypgmuzauV6KCSNujNHOdWkNEUNylOUAPS618jnIg,2559
|
|
30
|
-
jetpytools-1.7.
|
|
31
|
-
jetpytools-1.7.
|
|
32
|
-
jetpytools-1.7.
|
|
33
|
-
jetpytools-1.7.
|
|
30
|
+
jetpytools-1.7.4.dist-info/METADATA,sha256=DP5E8ygPnwnPuriFpgxkrCLDQUqjzU93xiU-m1XnmD0,1198
|
|
31
|
+
jetpytools-1.7.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
32
|
+
jetpytools-1.7.4.dist-info/licenses/LICENSE,sha256=l0PN-qDtXcgOB5aXP_nSUsvCK5V3o9pQCGsTzyZhKL0,1071
|
|
33
|
+
jetpytools-1.7.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|