jetpytools 1.3.0__tar.gz → 1.4.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.
- {jetpytools-1.3.0 → jetpytools-1.4.0}/PKG-INFO +1 -1
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/_metadata.py +1 -1
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/exceptions/base.py +3 -13
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/types/utils.py +22 -57
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools.egg-info/PKG-INFO +1 -1
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools.egg-info/SOURCES.txt +3 -1
- {jetpytools-1.3.0 → jetpytools-1.4.0}/setup.cfg +1 -0
- jetpytools-1.4.0/tests/test_funcs.py +12 -0
- jetpytools-1.4.0/tests/test_normalize.py +9 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/LICENSE +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/README.md +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/__init__.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/enums/__init__.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/enums/base.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/enums/other.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/exceptions/__init__.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/exceptions/enum.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/exceptions/file.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/exceptions/generic.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/exceptions/module.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/functions/__init__.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/functions/funcs.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/functions/normalize.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/functions/other.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/py.typed +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/types/__init__.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/types/builtins.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/types/check.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/types/file.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/types/funcs.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/types/generic.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/types/supports.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/utils/__init__.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/utils/file.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/utils/funcs.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/utils/math.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools/utils/ranges.py +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools.egg-info/dependency_links.txt +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools.egg-info/requires.txt +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/jetpytools.egg-info/top_level.txt +0 -0
- {jetpytools-1.3.0 → jetpytools-1.4.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Collection of stuff that's useful in general python programming"""
|
|
2
2
|
|
|
3
|
-
__version__ = '1.
|
|
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
|
-
|
|
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
|
-
|
|
113
|
-
...
|
|
103
|
+
warn("Custom error is not subscriptable anymore. Don't use it", DeprecationWarning)
|
|
114
104
|
|
|
115
|
-
return
|
|
105
|
+
return cls()
|
|
116
106
|
|
|
117
107
|
def __call__(
|
|
118
108
|
self,
|
|
@@ -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[
|
|
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:
|
|
437
|
-
fset:
|
|
438
|
-
fdel:
|
|
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.
|
|
431
|
+
self.__doc__ = doc
|
|
446
432
|
|
|
447
|
-
def _wrap(self, func:
|
|
448
|
-
if not isinstance(func,
|
|
449
|
-
func = classmethod(func)
|
|
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
|
|
437
|
+
return func
|
|
452
438
|
|
|
453
|
-
def
|
|
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)()
|
|
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
|
|
476
|
-
|
|
477
|
-
|
|
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
|
-
|
|
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
|
|
489
|
-
|
|
490
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from jetpytools import fallback, iterate
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_iterate() -> None:
|
|
7
|
+
assert iterate(5, lambda x: x * 2, 2) == 20
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_fallback() -> None:
|
|
11
|
+
assert fallback(5, 6) == 5
|
|
12
|
+
assert fallback(None, 6) == 6
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from jetpytools import normalize_ranges
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_normalize_ranges() -> None:
|
|
7
|
+
assert normalize_ranges((None, None), end=1000) == [(0, 999)]
|
|
8
|
+
assert normalize_ranges((24, -24), end=1000) == [(24, 975)]
|
|
9
|
+
assert normalize_ranges([(24, 100), (80, 150)], end=1000) == [(24, 150)]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|