jetpytools 2.0.0__py3-none-any.whl → 2.0.1__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__ = "2.0.0"
3
+ __version__ = "2.0.1"
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__
@@ -113,14 +113,16 @@ class ComparatorFunc(Protocol):
113
113
  ) -> T0 | T1: ...
114
114
 
115
115
 
116
+ @runtime_checkable
116
117
  class SupportsIndexing[T](Protocol):
117
118
  def __getitem__(self, k: int) -> T: ...
118
119
 
119
120
 
121
+ @runtime_checkable
120
122
  class SupportsKeysAndGetItem[KT, VT](Protocol):
121
123
  def keys(self) -> Iterable[KT]: ...
122
124
 
123
125
  def __getitem__(self, k: KT) -> VT: ...
124
126
 
125
127
 
126
- type SupportsFloatOrIndex = SupportsFloat | SupportsIndex
128
+ SupportsFloatOrIndex = SupportsFloat | SupportsIndex
jetpytools/types/utils.py CHANGED
@@ -192,10 +192,12 @@ class _InjectSelfBase(Generic[_T_co, _P, _R_co]):
192
192
  self.args = args
193
193
  self.kwargs = kwargs
194
194
 
195
- def __get__[T](self, instance: T | None, owner: type[T]) -> _InjectedSelfFunc[T, _P, _R_co]: # pyright: ignore[reportGeneralTypeIssues]
195
+ def __get__(self, instance: Any | None, owner: type | None = None) -> _InjectedSelfFunc[_T_co, _P, _R_co]: # pyright: ignore[reportGeneralTypeIssues]
196
196
  """
197
197
  Return a wrapped callable that automatically injects an instance as the first argument when called.
198
198
  """
199
+ if owner is None:
200
+ owner = type(instance)
199
201
 
200
202
  @wraps(self._function)
201
203
  def _wrapper(*args: Any, **kwargs: Any) -> _R_co:
@@ -263,6 +265,9 @@ class _InjectSelfBase(Generic[_T_co, _P, _R_co]):
263
265
 
264
266
  return owner(*self.args, **self.kwargs), kwargs
265
267
 
268
+ def __call__(self_, self: _T_co, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: # type: ignore[misc] # noqa: N805
269
+ return self_.__get__(self, type(self))(*args, **kwargs)
270
+
266
271
  @property
267
272
  def __func__(self) -> Callable[Concatenate[_T_co, _P], _R_co]:
268
273
  """Return the original wrapped function."""
@@ -377,10 +382,10 @@ class _InjectKwargsParamsBase(Generic[_T_co, _P, _R_co]):
377
382
  self._signature = None
378
383
 
379
384
  @overload
380
- def __get__(self, instance: None, owner: type[Any]) -> Self: ...
385
+ def __get__(self, instance: None, owner: type) -> Self: ...
381
386
  @overload
382
- def __get__(self, instance: Any, owner: type[Any]) -> Callable[_P, _R_co]: ...
383
- def __get__(self, instance: Any | None, owner: type[Any]) -> Self | Callable[_P, _R_co]:
387
+ def __get__(self, instance: Any, owner: type | None = None) -> Callable[_P, _R_co]: ...
388
+ def __get__(self, instance: Any | None, owner: type | None = None) -> Any:
384
389
  """
385
390
  Descriptor binding logic.
386
391
 
@@ -435,6 +440,9 @@ class _InjectKwargsParamsBase(Generic[_T_co, _P, _R_co]):
435
440
 
436
441
  return wrapper
437
442
 
443
+ def __call__(self_, self: _T_co, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: # type: ignore[misc] # noqa: N805
444
+ return self_.__get__(self, type(self))(*args, **kwargs)
445
+
438
446
  @property
439
447
  def __func__(self) -> Callable[Concatenate[_T_co, _P], _R_co]:
440
448
  """Return the original wrapped function."""
@@ -467,7 +475,7 @@ class _InjectKwargsParamsBase(Generic[_T_co, _P, _R_co]):
467
475
  return _wrapper
468
476
 
469
477
 
470
- class inject_kwargs_params[T, **P, R](_InjectKwargsParamsBase[T, P, R]):
478
+ class inject_kwargs_params(_InjectKwargsParamsBase[_T_co, _P, _R_co]):
471
479
  """
472
480
  Descriptor that injects parameters into functions based on an instance's keyword mapping.
473
481
 
@@ -478,7 +486,7 @@ class inject_kwargs_params[T, **P, R](_InjectKwargsParamsBase[T, P, R]):
478
486
 
479
487
  __slots__ = ()
480
488
 
481
- class add_to_kwargs[T0, **P0, R0](_InjectKwargsParamsBase[T0, P0, R0]):
489
+ class add_to_kwargs(_InjectKwargsParamsBase[_T0_co, _P0, _R0_co]):
482
490
  """
483
491
  Variant of `inject_kwargs_params` that merges unused entries from `self.kwargs` into the keyword arguments
484
492
  passed to the target function.
@@ -584,61 +592,59 @@ class classproperty_base(Generic[_T, _R_co, _T_Any]):
584
592
  def __set_name__(self, owner: object, name: str) -> None:
585
593
  self.__name__ = name
586
594
 
587
- def _get_cache(self, type_: type[_T]) -> dict[str, Any]:
595
+ def _get_cache(self, owner: type[_T]) -> dict[str, Any]:
588
596
  cache_key = getattr(self, "cache_key")
589
597
 
590
- if not hasattr(type_, cache_key):
591
- setattr(type_, cache_key, {})
598
+ if not hasattr(owner, cache_key):
599
+ setattr(owner, cache_key, {})
592
600
 
593
- return getattr(type_, cache_key)
601
+ return getattr(owner, cache_key)
594
602
 
595
- def __get__(self, obj: _T | None, type_: type[_T] | None = None) -> _R_co:
596
- if type_ is None and obj is not None:
597
- type_ = type(obj)
598
- elif type_ is None:
599
- raise NotImplementedError("Both obj and type_ are None")
603
+ def __get__(self, instance: Any | None, owner: type | None = None) -> _R_co:
604
+ if owner is None:
605
+ owner = type(instance)
600
606
 
601
607
  if not isinstance(self, classproperty.cached):
602
- return self.fget(type_)
608
+ return self.fget(owner)
603
609
 
604
- if self.__name__ in (cache := self._get_cache(type_)):
610
+ if self.__name__ in (cache := self._get_cache(owner)):
605
611
  return cache[self.__name__]
606
612
 
607
- value = self.fget(type_)
613
+ value = self.fget(owner)
608
614
  cache[self.__name__] = value
609
615
  return value
610
616
 
611
- def __set__(self, obj: _T, value: _T_Any) -> None:
617
+ def __set__(self, instance: Any, value: _T_Any) -> None:
612
618
  if not self.fset:
613
619
  raise AttributeError(
614
- f'classproperty with getter "{self.__name__}" of "{obj.__class__.__name__}" object has no setter.'
620
+ f'classproperty with getter "{self.__name__}" of "{instance.__class__.__name__}" object has no setter.'
615
621
  )
616
622
 
617
- type_ = type(obj)
623
+ owner = type(instance)
618
624
 
619
625
  if not isinstance(self, classproperty.cached):
620
- return self.fset(type_, value)
626
+ return self.fset(owner, value)
621
627
 
622
- if self.__name__ in (cache := self._get_cache(type_)):
628
+ if self.__name__ in (cache := self._get_cache(owner)):
623
629
  del cache[self.__name__]
624
630
 
625
- self.fset(type_, value)
631
+ self.fset(owner, value)
626
632
 
627
- def __delete__(self, obj: _T) -> None:
633
+ def __delete__(self, instance: Any) -> None:
628
634
  if not self.fdel:
629
635
  raise AttributeError(
630
- f'classproperty with getter "{self.__name__}" of "{obj.__class__.__name__}" object has no deleter.'
636
+ f'classproperty with getter "{self.__name__}" of "{instance.__class__.__name__}" object has no deleter.'
631
637
  )
632
638
 
633
- type_ = type(obj)
639
+ owner = type(instance)
634
640
 
635
641
  if not isinstance(self, classproperty.cached):
636
- return self.fdel(type_)
642
+ return self.fdel(owner)
637
643
 
638
- if self.__name__ in (cache := self._get_cache(type_)):
644
+ if self.__name__ in (cache := self._get_cache(owner)):
639
645
  del cache[self.__name__]
640
646
 
641
- self.fdel(type_)
647
+ self.fdel(owner)
642
648
 
643
649
 
644
650
  class classproperty(classproperty_base[_T, _R_co, _T_Any]):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jetpytools
3
- Version: 2.0.0
3
+ Version: 2.0.1
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=QeYkd0FebUmiwIAzUXzC3bAEDz8ahjql90oXjCZ7JVE,414
2
+ jetpytools/_metadata.py,sha256=Sh6w1MTmnsiXSW7bySj3rvnKAj6r6vq0Jf8-TqTi00Q,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=Vuzlv84jXUCje7-yoyjucPcgkmfVkLHuuLXcmx4z1Yw,1970
@@ -20,14 +20,14 @@ jetpytools/types/check.py,sha256=ktQOykmryUkDa2j-zcL6uEWF8QlxJ4GW8YKdbqMHGcc,959
20
20
  jetpytools/types/file.py,sha256=6hV332qbBtvg3p3g6tNHiSnZGp4DhtcTZm-Vap7M72k,6400
21
21
  jetpytools/types/funcs.py,sha256=arlykyVyosdjBhUTrJDfAoGBdkI5zhoJc0yINMQEonw,2804
22
22
  jetpytools/types/generic.py,sha256=LlYiD54GPi5ghjdw4wJmulrZiqv5IUnfPfyr-fk-RlA,1138
23
- jetpytools/types/supports.py,sha256=kzzQQaUs1MOqU9jZXu9lsN9ff9ay7dViftEDHkWTbSY,3367
24
- jetpytools/types/utils.py,sha256=Bm5zrAfKBgITcOkSemzuVhs44jEesBC73zDVHFBnXGc,29249
23
+ jetpytools/types/supports.py,sha256=uZ2N7XxAa5H3QcOKStCH8fp2x6EXvoKwLQZue5xTLFY,3400
24
+ jetpytools/types/utils.py,sha256=GoRx3fjHRbdQ27L4jkUb_oUXAtupGUI2FHHWp8ccEWw,29599
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=2jOOIUQpifQ_kTuVUSrCAi8hvCmmvieBpMTfF8XuM24,979
28
28
  jetpytools/utils/math.py,sha256=ZqsAyVNBT4LD-zqP7QxEkGwWdVfrR7YAkdv87NQTMV0,3460
29
29
  jetpytools/utils/ranges.py,sha256=RAknSZkTAYxAXdFn_CKY8xGASu7xS7Gu039DX89ugDc,1293
30
- jetpytools-2.0.0.dist-info/METADATA,sha256=glIX6YFKIMgzZcPxgr6DbXamv3ZsVJvzzM7UonTOcAc,1198
31
- jetpytools-2.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
- jetpytools-2.0.0.dist-info/licenses/LICENSE,sha256=l0PN-qDtXcgOB5aXP_nSUsvCK5V3o9pQCGsTzyZhKL0,1071
33
- jetpytools-2.0.0.dist-info/RECORD,,
30
+ jetpytools-2.0.1.dist-info/METADATA,sha256=c0AIK2JpabO43aUHc_3G-4wYSF4X19hcJw2goRGb-Oc,1198
31
+ jetpytools-2.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
+ jetpytools-2.0.1.dist-info/licenses/LICENSE,sha256=l0PN-qDtXcgOB5aXP_nSUsvCK5V3o9pQCGsTzyZhKL0,1071
33
+ jetpytools-2.0.1.dist-info/RECORD,,