danielutils 0.9.78__tar.gz → 0.9.81__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.
- {danielutils-0.9.78/danielutils.egg-info → danielutils-0.9.81}/PKG-INFO +2 -2
- {danielutils-0.9.78 → danielutils-0.9.81}/README.md +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/__init__.py +2 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/database/database.py +2 -2
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/multiprogramming/worker.py +3 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/multiprogramming/worker_pool.py +5 -5
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/repl.py +5 -5
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/typed_builtins/factory.py +6 -6
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/typed_builtins/tlist.py +2 -2
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/colors.py +1 -1
- danielutils-0.9.81/danielutils/context_managers/__init__.py +1 -0
- danielutils-0.9.81/danielutils/context_managers/temporary_file.py +34 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/conversions/main_conversions.py +9 -9
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/conversions/specialized_conversions/to_int.py +3 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/graph/graph.py +14 -14
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/graph/multinode.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/queue/queue.py +3 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/trees/binary_syntax_tree.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/date.py +2 -2
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/atomic.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/attach.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/decorate_conditionally.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/limit_recursion.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/memo.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/overload.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/partially_implemented.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/timeout.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/total_ordering.py +5 -5
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/validate.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/areoneof.py +3 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/isoftype.py +4 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/isoneof.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/multiloop.py +2 -2
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/types_subseteq.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/generators/generator_from_stream.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/generators/join_generators.py +5 -5
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/internet.py +7 -7
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/io_.py +35 -33
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/math_/functions.py +1 -1
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/math_/math_symbols.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/math_/polynomial/polinomial.py +6 -6
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/metaclasses/interface.py +6 -6
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/protocols/dictable.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/class_/class_reflection.py +9 -9
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/function/function_reflections.py +3 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/interpreter/get_traceback.py +3 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/interpreter/python_version.py +3 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/interpreter/tracer.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/module/package_reflection.py +8 -8
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/system/__init__.py +1 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/system/independent.py +14 -13
- danielutils-0.9.81/danielutils/system/layered_command.py +86 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/text.py +8 -8
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/tqdm_.py +4 -4
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/databases/all.py +20 -20
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/oop/observer.py +2 -2
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/discrete/geometric.py +3 -3
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/operator.py +9 -9
- danielutils-0.9.81/danielutils/versioned_imports.py +12 -0
- {danielutils-0.9.78 → danielutils-0.9.81/danielutils.egg-info}/PKG-INFO +2 -2
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils.egg-info/SOURCES.txt +3 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/pyproject.toml +1 -1
- danielutils-0.9.78/danielutils/versioned_imports.py +0 -21
- {danielutils-0.9.78 → danielutils-0.9.81}/LICENSE +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/MANIFEST.in +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/database/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/database/cached_database.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/database/redis_database.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/multiprogramming/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/multiprogramming/multi_id.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/aliases.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/counter.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/frange.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/typed_builtins/tdict.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/typed_builtins/tset.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/typed_builtins/ttuple.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/convenience.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/conversions/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/conversions/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/conversions/specialized_conversions/to_hex.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/comparer.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/default_dict.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/functions.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/graph/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/graph/binary_node.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/graph/node.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/heap/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/heap/heap.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/heap/max_heap.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/heap/min_heap.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/queue/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/queue/atomic_queue.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/queue/priority_queue.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/stack.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/trees/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/trees/binary_tree.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/date_time.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/chain_decorators.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/delay_call.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/deprecate.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/final.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/processify.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/property.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/singleton.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/decorators/threadify.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/exceptions.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/check_foreach.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/flatten.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/powerset.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/functions/subseteq.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/generators/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/generators/conditional_generator.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/math_/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/math_/constants.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/math_/math_print.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/math_/polynomial/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/metaclasses/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/metaclasses/atomic_class_meta.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/metaclasses/instance_cache_meta.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/metaclasses/overload_meta.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/mock_/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/mock_/mock_database.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/mock_/mock_module.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/path.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/print_.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/protocols/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/protocols/evaluable.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/py.typed +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/class_/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/file/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/file/file_reflection.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/function/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/interpreter/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/interpreter/callstack.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/interpreter/os_.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/interpreter/packages.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/interpreter/signals.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/module/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/reflection/module/module_reflections.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/snippets/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/snippets/try_get.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/system/windows/utils/filetime.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/time.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/databases/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/oop/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/oop/strategy.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/conditional_variable.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/continuous/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/discrete/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/discrete/bernoulli.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/discrete/binomial.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/discrete/conditional_from_discrete_probability_func.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/discrete/discrete.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/discrete/poisson.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/conditional_variable/discrete/uniform.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/distributions.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/expressions/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/expressions/accumulation_expression.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/expressions/probability_expression.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/funcs/__init__.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/funcs/covariance.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/funcs/expected_value.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/funcs/probability_function.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/funcs/variance.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/protocols.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/supp.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils/university/probability/transformation.py +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/setup.cfg +0 -0
- {danielutils-0.9.78 → danielutils-0.9.81}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.81
|
|
4
4
|
Summary: A python utils library for things I find useful
|
|
5
5
|
Author-email: danielnachumdev <danielnachumdev@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -41,7 +41,7 @@ License-File: LICENSE
|
|
|
41
41
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
42
42
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
43
43
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
44
|
-
# danielutils v=0.9.
|
|
44
|
+
# danielutils v=0.9.81
|
|
45
45
|
A utils library for things that I find useful for my coding workflow.\
|
|
46
46
|
Feel free to use and / or contribute / improve my code :)
|
|
47
47
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
5
5
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
6
6
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
7
|
-
# danielutils v=0.9.
|
|
7
|
+
# danielutils v=0.9.81
|
|
8
8
|
A utils library for things that I find useful for my coding workflow.\
|
|
9
9
|
Feel free to use and / or contribute / improve my code :)
|
|
10
10
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import Any, TypeVar, Generic, Optional
|
|
2
|
+
from typing import Any, TypeVar, Generic, Optional, Set
|
|
3
3
|
|
|
4
4
|
K = TypeVar('K')
|
|
5
5
|
V = TypeVar('V')
|
|
@@ -12,7 +12,7 @@ class Database(ABC, Generic[K, V]):
|
|
|
12
12
|
DEFAULT = None
|
|
13
13
|
|
|
14
14
|
def __init__(self) -> None:
|
|
15
|
-
self._subscribers:
|
|
15
|
+
self._subscribers: Set[Database] = set()
|
|
16
16
|
|
|
17
17
|
def _register_subscriber(self, subscriber: 'Database') -> None:
|
|
18
18
|
self._subscribers.add(subscriber)
|
{danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/multiprogramming/worker.py
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from threading import Thread
|
|
2
2
|
from abc import ABC, abstractmethod
|
|
3
|
-
from typing import Optional, Any,Tuple as
|
|
3
|
+
from typing import Optional, Any,Tuple as Tuple
|
|
4
4
|
from logging import error
|
|
5
5
|
import danielutils # this is explicitly this way to prevent circular import
|
|
6
6
|
from ...reflection import get_python_version
|
|
7
7
|
if get_python_version() >= (3, 9):
|
|
8
|
-
from builtins import tuple as
|
|
8
|
+
from builtins import tuple as Tuple # type:ignore
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class Worker(ABC):
|
|
@@ -59,7 +59,7 @@ class Worker(ABC):
|
|
|
59
59
|
"""
|
|
60
60
|
self.pool._notify_subscribers() # pylint: disable=protected-access
|
|
61
61
|
|
|
62
|
-
def acquire(self) -> Optional[
|
|
62
|
+
def acquire(self) -> Optional[Tuple[Any]]:
|
|
63
63
|
"""acquire a new job object to work on from the pool
|
|
64
64
|
will return a tuple of only one object (the job) or None if there are no more jobs
|
|
65
65
|
Returns:
|
{danielutils-0.9.78 → danielutils-0.9.81}/danielutils/abstractions/multiprogramming/worker_pool.py
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from queue import Queue
|
|
2
|
-
from typing import Optional, Any, Type as t_type, Tuple as
|
|
2
|
+
from typing import Optional, Any, Type as t_type, Tuple as Tuple, List as List
|
|
3
3
|
from threading import Semaphore
|
|
4
4
|
from .worker import Worker
|
|
5
5
|
from ...reflection import get_python_version
|
|
6
6
|
|
|
7
7
|
if get_python_version() >= (3, 9):
|
|
8
|
-
from builtins import type as t_type, tuple as
|
|
8
|
+
from builtins import type as t_type, tuple as Tuple, list as List # type:ignore
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class WorkerPool:
|
|
@@ -15,9 +15,9 @@ class WorkerPool:
|
|
|
15
15
|
def __init__(self, num_workers: int, worker_class: t_type[Worker], w_kwargs: dict, global_variables: dict) -> None:
|
|
16
16
|
self.num_workers = num_workers
|
|
17
17
|
self.global_variables: dict = global_variables
|
|
18
|
-
self.q: Queue[
|
|
18
|
+
self.q: Queue[Tuple[Any]] = Queue()
|
|
19
19
|
self.worker_class = worker_class
|
|
20
|
-
self.workers:
|
|
20
|
+
self.workers: List[Worker] = []
|
|
21
21
|
self.sem = Semaphore(0)
|
|
22
22
|
self.w_kwargs = w_kwargs
|
|
23
23
|
|
|
@@ -34,7 +34,7 @@ class WorkerPool:
|
|
|
34
34
|
self.q.put((job,))
|
|
35
35
|
self.sem.release()
|
|
36
36
|
|
|
37
|
-
def _acquire(self) -> Optional[
|
|
37
|
+
def _acquire(self) -> Optional[Tuple[Any]]:
|
|
38
38
|
"""acquire a new job from the pool
|
|
39
39
|
|
|
40
40
|
Returns:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import copy, re
|
|
2
|
-
from typing import Any, Callable, Union, Tuple as
|
|
2
|
+
from typing import Any, Callable, Union, Tuple as Tuple, List as List, Dict as Dict
|
|
3
3
|
from ..reflection import get_python_version # pylint :disable=relative-beyond-top-level
|
|
4
4
|
|
|
5
5
|
if get_python_version() >= (3, 9):
|
|
6
|
-
from builtins import tuple as
|
|
6
|
+
from builtins import tuple as Tuple, list as List, dict as Dict # type:ignore
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class Argument:
|
|
@@ -20,7 +20,7 @@ class Command:
|
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
def __init__(self, command: Union[Argument, str], callback: Callable,
|
|
23
|
-
explanation: str = "", *, options:
|
|
23
|
+
explanation: str = "", *, options: Tuple[Argument, ...] = tuple()) -> None:
|
|
24
24
|
self.command = command if isinstance(
|
|
25
25
|
command, Argument) else Argument(command)
|
|
26
26
|
self.callback = callback
|
|
@@ -41,10 +41,10 @@ class REPL:
|
|
|
41
41
|
"""
|
|
42
42
|
|
|
43
43
|
# pylint: disable=dangerous-default-value
|
|
44
|
-
def __init__(self, routes:
|
|
44
|
+
def __init__(self, routes: List[Command], *, prompt_symbol: str = ">>> ", exit_keywords: set = {"exit", "quit"}):
|
|
45
45
|
self.prompt_symbol = prompt_symbol
|
|
46
46
|
self.exit_keywords = copy.copy(exit_keywords)
|
|
47
|
-
self.routes:
|
|
47
|
+
self.routes: Dict[str, Command] = {
|
|
48
48
|
com.command.name: com for com in routes}
|
|
49
49
|
|
|
50
50
|
def run(self) -> None:
|
{danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/typed_builtins/factory.py
RENAMED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import types
|
|
2
2
|
from abc import abstractmethod
|
|
3
|
-
from typing import Any, Iterable, List as
|
|
3
|
+
from typing import Any, Iterable, List as List, Set as Set, Dict as Dict, Tuple as Tuple
|
|
4
4
|
from ...functions import types_subseteq, isoftype
|
|
5
5
|
from ...reflection import get_caller_name, get_python_version
|
|
6
6
|
|
|
7
7
|
if get_python_version() >= (3, 9):
|
|
8
|
-
from builtins import list as
|
|
8
|
+
from builtins import list as List, set as Set, dict as Dict, tuple as Tuple # type:ignore
|
|
9
9
|
# needed for python 3.8
|
|
10
10
|
class_to_type = {
|
|
11
|
-
list:
|
|
12
|
-
set:
|
|
13
|
-
dict:
|
|
14
|
-
|
|
11
|
+
list: List,
|
|
12
|
+
set: Set,
|
|
13
|
+
dict: Dict,
|
|
14
|
+
Tuple: Tuple,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
|
{danielutils-0.9.78 → danielutils-0.9.81}/danielutils/better_builtins/typed_builtins/tlist.py
RENAMED
|
@@ -7,7 +7,7 @@ from .factory import create_typed_class
|
|
|
7
7
|
T = TypeVar("T", bound=Any)
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
# class ptlist(
|
|
10
|
+
# class ptlist(List[T], Generic[T]):
|
|
11
11
|
# """like 'list' but with runtime type safety
|
|
12
12
|
# """
|
|
13
13
|
|
|
@@ -18,7 +18,7 @@ T = TypeVar("T", bound=Any)
|
|
|
18
18
|
# def __instancecheck__(self, instance: Any) -> bool:
|
|
19
19
|
# if isinstance(instance, ptlist):
|
|
20
20
|
# return types_subseteq(instance._params, self._params)
|
|
21
|
-
# return isoftype(instance,
|
|
21
|
+
# return isoftype(instance, List[self._params]) # type: ignore
|
|
22
22
|
|
|
23
23
|
# def __init__(self, item) -> None:
|
|
24
24
|
# if not get_caller_name(0) == "__class_getitem__":
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .temporary_file import *
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from ..io_ import file_exists, delete_file
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class TemporaryFile:
|
|
5
|
+
def __init__(self, path: str):
|
|
6
|
+
if file_exists(path):
|
|
7
|
+
raise RuntimeError(f"Can't create a temporary file if file '{path}' already exists.")
|
|
8
|
+
self.path = path
|
|
9
|
+
|
|
10
|
+
def __enter__(self):
|
|
11
|
+
return self
|
|
12
|
+
|
|
13
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
14
|
+
self.close()
|
|
15
|
+
|
|
16
|
+
def close(self) -> None:
|
|
17
|
+
delete_file(self.path)
|
|
18
|
+
|
|
19
|
+
def read(self) -> list[str]:
|
|
20
|
+
with open(self.path, 'r') as f:
|
|
21
|
+
return f.readlines()
|
|
22
|
+
|
|
23
|
+
def write(self, lines: list[str]) -> None:
|
|
24
|
+
with open(self.path, 'a') as f:
|
|
25
|
+
f.writelines(lines)
|
|
26
|
+
|
|
27
|
+
def clear(self):
|
|
28
|
+
with open(self.path, 'w') as _:
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
__all__ = [
|
|
33
|
+
'TemporaryFile'
|
|
34
|
+
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from ..decorators import validate
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
@validate
|
|
4
|
+
@validate # type:ignore
|
|
5
5
|
def char_to_int(c: str) -> int:
|
|
6
6
|
"""convert char to its representing int value
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ def char_to_int(c: str) -> int:
|
|
|
14
14
|
return ord(c)
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
@validate
|
|
17
|
+
@validate # type:ignore
|
|
18
18
|
def int_to_char(num: int) -> str:
|
|
19
19
|
"""convert int to its corresponding char
|
|
20
20
|
|
|
@@ -27,7 +27,7 @@ def int_to_char(num: int) -> str:
|
|
|
27
27
|
return chr(num)
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
@validate
|
|
30
|
+
@validate # type:ignore
|
|
31
31
|
def hex_to_char(h: str) -> str:
|
|
32
32
|
"""convert hex number to char
|
|
33
33
|
|
|
@@ -40,7 +40,7 @@ def hex_to_char(h: str) -> str:
|
|
|
40
40
|
return int_to_char(hex_to_dec(h))
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
@validate
|
|
43
|
+
@validate # type:ignore
|
|
44
44
|
def hex_to_dec(h: str) -> int:
|
|
45
45
|
"""convert hex to dec
|
|
46
46
|
|
|
@@ -53,7 +53,7 @@ def hex_to_dec(h: str) -> int:
|
|
|
53
53
|
return int(h, 16)
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
@validate
|
|
56
|
+
@validate # type:ignore
|
|
57
57
|
def char_to_hex(c: str) -> str:
|
|
58
58
|
"""convert char to hex
|
|
59
59
|
|
|
@@ -66,7 +66,7 @@ def char_to_hex(c: str) -> str:
|
|
|
66
66
|
return int_to_hex(char_to_int(c))
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
@validate
|
|
69
|
+
@validate # type:ignore
|
|
70
70
|
def dec_to_hex(num: int) -> str:
|
|
71
71
|
"""convert decimal number to hex
|
|
72
72
|
|
|
@@ -79,7 +79,7 @@ def dec_to_hex(num: int) -> str:
|
|
|
79
79
|
return int_to_hex(num)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
@validate
|
|
82
|
+
@validate # type:ignore
|
|
83
83
|
def int_to_hex(num: int) -> str:
|
|
84
84
|
"""converts an int to it's hex representation
|
|
85
85
|
|
|
@@ -92,7 +92,7 @@ def int_to_hex(num: int) -> str:
|
|
|
92
92
|
return hex(num)
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
@validate
|
|
95
|
+
@validate # type:ignore
|
|
96
96
|
def bytes_to_str(b: bytes) -> str:
|
|
97
97
|
"""decodes bytes to str
|
|
98
98
|
|
|
@@ -105,7 +105,7 @@ def bytes_to_str(b: bytes) -> str:
|
|
|
105
105
|
return b.decode("utf-8")
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
@validate
|
|
108
|
+
@validate # type:ignore
|
|
109
109
|
def str_to_bytes(s: str) -> bytes:
|
|
110
110
|
"""encodes a string to bytes
|
|
111
111
|
|
{danielutils-0.9.78 → danielutils-0.9.81}/danielutils/conversions/specialized_conversions/to_int.py
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"""functions that convert values to int"""
|
|
2
|
-
from typing import Union, List as
|
|
2
|
+
from typing import Union, List as List
|
|
3
3
|
from ..main_conversions import char_to_int
|
|
4
4
|
from ...reflection import get_python_version
|
|
5
5
|
if get_python_version() >= (3, 9):
|
|
6
|
-
from builtins import list as
|
|
6
|
+
from builtins import list as List
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def to_int(value: str) -> Union[int,
|
|
9
|
+
def to_int(value: str) -> Union[int, List[int]]:
|
|
10
10
|
"""converts a single character or a full string to an int or list of int respectively
|
|
11
11
|
"""
|
|
12
12
|
if len(value) == 1:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
from typing import Optional, Generator, List as
|
|
1
|
+
from typing import Optional, Generator, List as List, Set as Set, Dict as Dict, Generic, \
|
|
2
2
|
TypeVar, Iterable, Iterator
|
|
3
3
|
from ..queue import Queue
|
|
4
4
|
from .multinode import MultiNode
|
|
5
5
|
from ...reflection import get_python_version
|
|
6
6
|
|
|
7
7
|
if get_python_version() >= (3, 9):
|
|
8
|
-
from builtins import list as
|
|
8
|
+
from builtins import list as List, set as Set, dict as Dict
|
|
9
9
|
|
|
10
10
|
T = TypeVar("T")
|
|
11
11
|
|
|
@@ -16,11 +16,11 @@ class Graph(Generic[T]):
|
|
|
16
16
|
This class represents a directed graph, where nodes can be connected through edges.
|
|
17
17
|
|
|
18
18
|
Attributes:
|
|
19
|
-
nodes (Optional[
|
|
19
|
+
nodes (Optional[List[MultiNode]]): A list of MultiNode instances representing the nodes in the graph.
|
|
20
20
|
Default is an empty list.
|
|
21
21
|
|
|
22
22
|
Methods:
|
|
23
|
-
__init__(self, nodes: Optional[
|
|
23
|
+
__init__(self, nodes: Optional[List[MultiNode]] = None): Initialize the Graph with given nodes.
|
|
24
24
|
add_node(self, node): Add a node to the graph.
|
|
25
25
|
_extended_dfs(self) -> Generator: Perform an extended depth-first search on the graph.
|
|
26
26
|
dfs(self) -> Generator: Perform a depth-first search on the graph.
|
|
@@ -30,13 +30,13 @@ class Graph(Generic[T]):
|
|
|
30
30
|
|
|
31
31
|
"""
|
|
32
32
|
|
|
33
|
-
def to_dict(self) ->
|
|
33
|
+
def to_dict(self) -> Dict[T, Set[T]]:
|
|
34
34
|
"""
|
|
35
35
|
converts the graph to a dictionary.
|
|
36
36
|
Returns:
|
|
37
37
|
dict: A dictionary representing the graph.
|
|
38
38
|
"""
|
|
39
|
-
dct:
|
|
39
|
+
dct: Dict[T, Set[T]] = {}
|
|
40
40
|
for node in self:
|
|
41
41
|
v = dct.get(node.data, set())
|
|
42
42
|
for child in node:
|
|
@@ -45,7 +45,7 @@ class Graph(Generic[T]):
|
|
|
45
45
|
return dct
|
|
46
46
|
|
|
47
47
|
@staticmethod
|
|
48
|
-
def from_dict(dct:
|
|
48
|
+
def from_dict(dct: Dict[T, Iterable[T]]) -> "Graph[T]":
|
|
49
49
|
"""
|
|
50
50
|
converts a dictionary to a graph.
|
|
51
51
|
Args:
|
|
@@ -55,7 +55,7 @@ class Graph(Generic[T]):
|
|
|
55
55
|
Graph[T]: A graph representing the given dictionary.
|
|
56
56
|
"""
|
|
57
57
|
g: Graph[T] = Graph()
|
|
58
|
-
seen:
|
|
58
|
+
seen: Dict[T, MultiNode[T]] = {}
|
|
59
59
|
for k, v in dct.items():
|
|
60
60
|
seen[k] = seen.get(k, MultiNode(k))
|
|
61
61
|
|
|
@@ -66,8 +66,8 @@ class Graph(Generic[T]):
|
|
|
66
66
|
g.add_node(seen[k])
|
|
67
67
|
return g
|
|
68
68
|
|
|
69
|
-
def __init__(self, nodes: Optional[
|
|
70
|
-
self.nodes:
|
|
69
|
+
def __init__(self, nodes: Optional[List[MultiNode[T]]] = None):
|
|
70
|
+
self.nodes: List[MultiNode[T]] = nodes if nodes is not None else []
|
|
71
71
|
|
|
72
72
|
def add_node(self, node: MultiNode[T]) -> None:
|
|
73
73
|
"""Add a node to the graph.
|
|
@@ -77,7 +77,7 @@ class Graph(Generic[T]):
|
|
|
77
77
|
"""
|
|
78
78
|
self.nodes.append(node)
|
|
79
79
|
|
|
80
|
-
def _extended_dfs(self) -> Generator[MultiNode[T], None,
|
|
80
|
+
def _extended_dfs(self) -> Generator[MultiNode[T], None, List[MultiNode[T]]]:
|
|
81
81
|
"""Perform an extended depth-first search on the graph.
|
|
82
82
|
|
|
83
83
|
This private method performs an extended depth-first search (DFS) on the graph,
|
|
@@ -91,7 +91,7 @@ class Graph(Generic[T]):
|
|
|
91
91
|
enter_times: dict = {}
|
|
92
92
|
exit_times: dict = {}
|
|
93
93
|
travel_index: int = 1
|
|
94
|
-
all_nodes:
|
|
94
|
+
all_nodes: List[MultiNode] = []
|
|
95
95
|
|
|
96
96
|
def handle_node(node: MultiNode[T]) -> Generator[MultiNode[T], None, None]:
|
|
97
97
|
nonlocal travel_index
|
|
@@ -143,7 +143,7 @@ class Graph(Generic[T]):
|
|
|
143
143
|
"""
|
|
144
144
|
yield from self._extended_dfs()
|
|
145
145
|
|
|
146
|
-
def topological_sort(self) ->
|
|
146
|
+
def topological_sort(self) -> List[MultiNode[T]]:
|
|
147
147
|
"""Get a topological sort of the graph nodes.
|
|
148
148
|
|
|
149
149
|
This method performs a topological sort on the graph using the private _extended_dfs method.
|
|
@@ -169,7 +169,7 @@ class Graph(Generic[T]):
|
|
|
169
169
|
q: Queue[MultiNode[T]] = Queue()
|
|
170
170
|
for node in self.nodes:
|
|
171
171
|
q.push(node)
|
|
172
|
-
seen:
|
|
172
|
+
seen: Set[MultiNode] = set()
|
|
173
173
|
for node in q:
|
|
174
174
|
if node not in seen:
|
|
175
175
|
seen.add(node)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from typing import Optional, Generator, TypeVar, Generic, List as
|
|
1
|
+
from typing import Optional, Generator, TypeVar, Generic, List as List
|
|
2
2
|
|
|
3
3
|
from ...reflection import get_python_version
|
|
4
4
|
|
|
5
5
|
if get_python_version() >= (3, 9):
|
|
6
|
-
from builtins import list as
|
|
6
|
+
from builtins import list as List
|
|
7
7
|
T = TypeVar("T")
|
|
8
8
|
|
|
9
9
|
|
|
@@ -11,9 +11,9 @@ class MultiNode(Generic[T]):
|
|
|
11
11
|
"""A node class with no limit to children amount
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
def __init__(self, data: T, children: Optional[
|
|
14
|
+
def __init__(self, data: T, children: Optional[List[Optional['MultiNode[T]']]] = None):
|
|
15
15
|
self.data: T = data
|
|
16
|
-
self._children:
|
|
16
|
+
self._children: List[Optional[MultiNode[T]]] = children if children is not None else []
|
|
17
17
|
|
|
18
18
|
def __getitem__(self, index) -> T:
|
|
19
19
|
return self._children[index]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from typing import Generic, TypeVar, Iterator, List as
|
|
1
|
+
from typing import Generic, TypeVar, Iterator, List as List
|
|
2
2
|
from ...reflection import get_python_version
|
|
3
3
|
|
|
4
4
|
if get_python_version() >= (3, 9):
|
|
5
|
-
from builtins import list as
|
|
5
|
+
from builtins import list as List
|
|
6
6
|
T = TypeVar("T")
|
|
7
7
|
|
|
8
8
|
|
|
@@ -57,7 +57,7 @@ class Queue(Generic[T]):
|
|
|
57
57
|
def __iter__(self) -> Iterator[T]:
|
|
58
58
|
return iter(self.data)
|
|
59
59
|
|
|
60
|
-
def push_many(self, arr:
|
|
60
|
+
def push_many(self, arr: List[T]):
|
|
61
61
|
"""will push many objects to the Queue
|
|
62
62
|
|
|
63
63
|
Args:
|
{danielutils-0.9.78 → danielutils-0.9.81}/danielutils/data_structures/trees/binary_syntax_tree.py
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from typing import Union, Any, Callable,Dict as
|
|
1
|
+
from typing import Union, Any, Callable,Dict as Dict
|
|
2
2
|
from .binary_tree import BinaryTree
|
|
3
3
|
from ..graph import BinaryNode
|
|
4
4
|
from ...reflection import get_python_version
|
|
5
5
|
if get_python_version()>=(3,9):
|
|
6
|
-
from builtins import dict as
|
|
6
|
+
from builtins import dict as Dict
|
|
7
7
|
|
|
8
8
|
class BinarySyntaxTree(BinaryTree):
|
|
9
9
|
"""
|
|
@@ -11,7 +11,7 @@ class BinarySyntaxTree(BinaryTree):
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
@staticmethod
|
|
14
|
-
def _evaluate_node(v: BinaryNode, operator_func_dict:
|
|
14
|
+
def _evaluate_node(v: BinaryNode, operator_func_dict: Dict[Any, Callable[[Any, Any], Any]]):
|
|
15
15
|
if not isinstance(v, BinaryNode) or v.left is None and v.right is None:
|
|
16
16
|
return v
|
|
17
17
|
|
|
@@ -74,7 +74,7 @@ class BinarySyntaxTree(BinaryTree):
|
|
|
74
74
|
def __reversed__(self) -> "BinarySyntaxTree":
|
|
75
75
|
return self.reverse()
|
|
76
76
|
|
|
77
|
-
def evaluate(self, operator_func_dict:
|
|
77
|
+
def evaluate(self, operator_func_dict: Dict[Any, Callable[[Any, Any], Any]]) -> Any:
|
|
78
78
|
return BinarySyntaxTree._evaluate_node(self.root, operator_func_dict)
|
|
79
79
|
|
|
80
80
|
|
|
@@ -2,7 +2,7 @@ import json
|
|
|
2
2
|
from .decorators import validate
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
@validate
|
|
5
|
+
@validate # type:ignore # type:ignore
|
|
6
6
|
def dict_to_json(dct: dict) -> str:
|
|
7
7
|
"""converts a python dict to a json object
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ def dict_to_json(dct: dict) -> str:
|
|
|
15
15
|
return json.dumps(dct, indent=4)
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
@validate
|
|
18
|
+
@validate # type:ignore
|
|
19
19
|
def json_to_dict(json_str: str) -> dict:
|
|
20
20
|
"""converts a json object from a string to a python dict
|
|
21
21
|
|
|
@@ -8,7 +8,7 @@ P = ParamSpec("P")
|
|
|
8
8
|
FuncT = Callable[P, T] # type:ignore
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
@validate(strict=False)
|
|
11
|
+
@validate # type:ignore(strict=False)
|
|
12
12
|
def attach(before: Optional[Callable] = None, after: Optional[Callable] = None) -> Callable[[FuncT], FuncT]:
|
|
13
13
|
"""attaching functions to a function
|
|
14
14
|
|
|
@@ -3,7 +3,7 @@ from typing import Callable, Optional, Union
|
|
|
3
3
|
from .validate import validate
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
@validate(strict=False)
|
|
6
|
+
@validate # type:ignore(strict=False)
|
|
7
7
|
def decorate_conditionally(decorator: Callable, predicate: Union[bool, Callable[[], bool]], *,
|
|
8
8
|
decorator_args: Optional[list] = None, decorator_kwargs: Optional[dict] = None):
|
|
9
9
|
"""will decorate a function iff the predicate is True or returns True
|
|
@@ -11,7 +11,7 @@ P = ParamSpec("P")
|
|
|
11
11
|
FuncT = Callable[P, T] # type:ignore
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
@validate
|
|
14
|
+
@validate # type:ignore
|
|
15
15
|
def limit_recursion(max_depth: int, return_value: Any = None, quiet: bool = True) -> Callable[[FuncT], FuncT]:
|
|
16
16
|
"""decorator to limit recursion of functions
|
|
17
17
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import functools
|
|
2
|
-
from typing import Callable, Any, TypeVar, Dict
|
|
2
|
+
from typing import Callable, Any, TypeVar, Dict
|
|
3
3
|
from copy import deepcopy
|
|
4
4
|
from .validate import validate
|
|
5
|
-
from ..versioned_imports import ParamSpec
|
|
5
|
+
from ..versioned_imports import ParamSpec
|
|
6
6
|
|
|
7
7
|
T = TypeVar("T")
|
|
8
8
|
P = ParamSpec("P")
|
|
9
9
|
FuncT = Callable[P, T] # type:ignore
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
@validate
|
|
12
|
+
@validate # type:ignore
|
|
13
13
|
def memo(func: FuncT) -> FuncT:
|
|
14
14
|
"""decorator to memorize function calls in order to improve performance by using more memory
|
|
15
15
|
|
|
16
16
|
Args:
|
|
17
17
|
func (Callable): function to memorize
|
|
18
18
|
"""
|
|
19
|
-
cache:
|
|
19
|
+
cache: Dict[tuple, Any] = {}
|
|
20
20
|
|
|
21
21
|
@functools.wraps(func)
|
|
22
22
|
def wrapper(*args, **kwargs):
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
from typing import Callable, cast, Any, TypeVar, Dict
|
|
1
|
+
from typing import Callable, cast, Any, TypeVar, Dict
|
|
2
2
|
import inspect
|
|
3
3
|
import functools
|
|
4
4
|
from ..reflection import is_function_annotated_properly
|
|
5
5
|
from ..functions import isoftype, isoneof, isoneof_strict
|
|
6
6
|
from ..exceptions import OverloadDuplication, OverloadNotFound
|
|
7
7
|
from .deprecate import deprecate
|
|
8
|
-
from ..versioned_imports import ParamSpec
|
|
8
|
+
from ..versioned_imports import ParamSpec
|
|
9
9
|
|
|
10
10
|
T = TypeVar("T")
|
|
11
11
|
P = ParamSpec("P")
|
|
@@ -14,7 +14,7 @@ T2 = TypeVar("T2")
|
|
|
14
14
|
P2 = ParamSpec("P2")
|
|
15
15
|
FuncT2 = Callable[P2, T2] # type:ignore
|
|
16
16
|
|
|
17
|
-
__overload_dict:
|
|
17
|
+
__overload_dict: Dict[str, Dict[tuple, Callable]] = {}
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
@deprecate("'explicit_global_overload' is a legacy decorator please use 'overload' instead")
|
|
@@ -122,7 +122,7 @@ class overload:
|
|
|
122
122
|
overload._validate(func)
|
|
123
123
|
self._qualname = func.__qualname__
|
|
124
124
|
self._moudle = func.__module__
|
|
125
|
-
self._functions:
|
|
125
|
+
self._functions: Dict[int, Dict[Callable]] = {}
|
|
126
126
|
self._functions[overload._get_key(func)] = [func]
|
|
127
127
|
functools.wraps(func)(self)
|
|
128
128
|
|