py-cachify 2.0.9__tar.gz → 2.1.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.
@@ -0,0 +1,325 @@
1
+ .idea
2
+ .ipynb_checkpoints
3
+ .mypy_cache
4
+ .vscode
5
+ __pycache__
6
+ .pytest_cache
7
+ htmlcov
8
+ dist
9
+ site
10
+ .coverage
11
+ coverage.json
12
+ coverage.xml
13
+ .netlify
14
+ test.db
15
+ log.txt
16
+ Pipfile.lock
17
+ env3.*
18
+ env
19
+ docs_build
20
+ site_build
21
+ venv
22
+ docs.zip
23
+ archive.zip
24
+ .zed
25
+ .zed/*
26
+ # vim temporary files
27
+ *~
28
+ .*.sw?
29
+ .cache
30
+
31
+ # macOS
32
+ .DS_Store
33
+
34
+
35
+ ### Python template
36
+ # Byte-compiled / optimized / DLL files
37
+ __pycache__/
38
+ *.py[cod]
39
+ *$py.class
40
+
41
+ # C extensions
42
+ *.so
43
+
44
+ # Distribution / packaging
45
+
46
+ .Python
47
+ develop-eggs/
48
+ dist/
49
+ downloads/
50
+ eggs/
51
+ .eggs/
52
+ lib64/
53
+ parts/
54
+ sdist/
55
+ var/
56
+ wheels/
57
+ *.egg-info/
58
+ .installed.cfg
59
+ *.egg
60
+ pyrightconfig.json
61
+ .zed
62
+
63
+ # PyInstaller
64
+ # Usually these files are written by a python script from a template
65
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
66
+ *.manifest
67
+ *.spec
68
+
69
+ # Installer logs
70
+ pip-log.txt
71
+ pip-delete-this-directory.txt
72
+
73
+ # Unit test / coverage reports
74
+ htmlcov/
75
+ test-reports/
76
+ .tox/
77
+ .coverage.*
78
+ nosetests.xml
79
+ *.cover
80
+ .hypothesis/
81
+
82
+ # Translations
83
+ *.mo
84
+ *.pot
85
+
86
+ # Django stuff:
87
+ staticfiles/
88
+
89
+ # Sphinx documentation
90
+ docs/_build/
91
+
92
+ # PyBuilder
93
+ target/
94
+
95
+ # pyenv
96
+ .python-version
97
+
98
+ # celery beat schedule file
99
+ celerybeat-schedule
100
+
101
+ # Environments
102
+ .venv
103
+ venv/
104
+ ENV/
105
+
106
+ # Rope project settings
107
+ .ropeproject
108
+
109
+ # mkdocs documentation
110
+ /site
111
+
112
+ # mypy
113
+ .mypy_cache/
114
+
115
+ # ruff
116
+ .ruff_cache
117
+
118
+ ### Node template
119
+ # Logs
120
+ logs
121
+ *.log
122
+ npm-debug.log*
123
+ yarn-debug.log*
124
+ yarn-error.log*
125
+
126
+ # Runtime data
127
+ pids
128
+ *.pid
129
+ *.seed
130
+ *.pid.lock
131
+
132
+ # Directory for instrumented libs generated by jscoverage/JSCover
133
+ lib-cov
134
+
135
+ # Coverage directory used by tools like istanbul
136
+ coverage
137
+
138
+ # nyc test coverage
139
+ .nyc_output
140
+
141
+ # Bower dependency directory (https://bower.io/)
142
+ bower_components
143
+
144
+ # node-waf configuration
145
+ .lock-wscript
146
+
147
+ # Compiled binary addons (http://nodejs.org/api/addons.html)
148
+ build/Release
149
+
150
+ # Dependency directories
151
+ node_modules/
152
+ jspm_packages/
153
+
154
+ # Typescript v1 declaration files
155
+ typings/
156
+
157
+ # Optional npm cache directory
158
+ .npm
159
+
160
+ # Optional eslint cache
161
+ .eslintcache
162
+
163
+ # Optional REPL history
164
+ .node_repl_history
165
+
166
+ # Output of 'npm pack'
167
+ *.tgz
168
+
169
+ # Yarn Integrity file
170
+ .yarn-integrity
171
+
172
+
173
+ ### Linux template
174
+ # temporary files which can be created if a process still has a handle open of a deleted file
175
+ .fuse_hidden*
176
+
177
+ # KDE directory preferences
178
+ .directory
179
+
180
+ # Linux trash folder which might appear on any partition or disk
181
+ .Trash-*
182
+
183
+ # .nfs files are created when an open file is removed but is still being accessed
184
+ .nfs*
185
+
186
+
187
+ ### VisualStudioCode template
188
+ .vscode/*
189
+
190
+ .idea/*
191
+
192
+ # CMake
193
+ cmake-build-debug/
194
+
195
+ ## File-based project format:
196
+ *.iws
197
+
198
+ ## Plugin-specific files:
199
+
200
+ # IntelliJ
201
+ out/
202
+
203
+ # mpeltonen/sbt-idea plugin
204
+ .idea_modules/
205
+
206
+ # JIRA plugin
207
+ atlassian-ide-plugin.xml
208
+
209
+ # Crashlytics plugin (for Android Studio and IntelliJ)
210
+ com_crashlytics_export_strings.xml
211
+ crashlytics.properties
212
+ crashlytics-build.properties
213
+ fabric.properties
214
+
215
+ ### SublimeText template
216
+ # Cache files for Sublime Text
217
+ *.tmlanguage.cache
218
+ *.tmPreferences.cache
219
+ *.stTheme.cache
220
+
221
+ # Workspace files are user-specific
222
+ *.sublime-workspace
223
+
224
+ # Project files should be checked into the repository, unless a significant
225
+ # proportion of contributors will probably not be using Sublime Text
226
+ # *.sublime-project
227
+
228
+ # SFTP configuration file
229
+ sftp-config.json
230
+
231
+ # Package control specific files
232
+ Package Control.last-run
233
+ Package Control.ca-list
234
+ Package Control.ca-bundle
235
+ Package Control.system-ca-bundle
236
+ Package Control.cache/
237
+ Package Control.ca-certs/
238
+ Package Control.merged-ca-bundle
239
+ Package Control.user-ca-bundle
240
+ oscrypto-ca-bundle.crt
241
+ bh_unicode_properties.cache
242
+
243
+ # Sublime-github package stores a github token in this file
244
+ # https://packagecontrol.io/packages/sublime-github
245
+ GitHub.sublime-settings
246
+
247
+ ### Emacs template
248
+ .\#*
249
+
250
+ ### Vim template
251
+ # Swap
252
+ [._]*.s[a-v][a-z]
253
+ [._]*.sw[a-p]
254
+ [._]s[a-v][a-z]
255
+ [._]sw[a-p]
256
+
257
+ # Session
258
+ Session.vim
259
+
260
+ # Temporary
261
+ .netrwhist
262
+
263
+ # Auto-generated tag files
264
+ tags
265
+
266
+ .pytest_cache/
267
+ .env
268
+ src/settings/.env
269
+ .envs/*
270
+ !.envs/.local/
271
+
272
+ backups/
273
+ *.sql
274
+ *.sql.gz
275
+ **/*.sqlite3
276
+
277
+ ### Jupyter Notebook
278
+
279
+ **/.ipynb_checkpoints
280
+ jupyter/
281
+
282
+ ### Rest Idea Envs
283
+ *.env.json
284
+
285
+ etc/
286
+ docker-compose.local.*
287
+
288
+ *.iml
289
+
290
+
291
+ *htmlcov*
292
+
293
+ *.pyc
294
+ db.sqlite3
295
+ media
296
+
297
+ # Backup files
298
+ *.bak
299
+
300
+ # User-specific stuff
301
+ .idea/
302
+
303
+ # Distribution / packaging
304
+ .Python build/
305
+
306
+ # celery
307
+ celerybeat-schedule.*
308
+
309
+ # SageMath parsed files
310
+ *.sage.py
311
+
312
+ env.bak/
313
+ venv.bak/
314
+
315
+ *.sublime-project
316
+
317
+ # Package control specific files Package
318
+ Control.last-run
319
+ Control.ca-list
320
+ Control.ca-bundle
321
+ Control.system-ca-bundle
322
+
323
+ # Visual Studio Code #
324
+ .vscode/
325
+ .history
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 EzyGang
3
+ Copyright (c) 2024-2025 EzyGang
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,12 +1,12 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: py-cachify
3
- Version: 2.0.9
3
+ Version: 2.1.0
4
4
  Summary: Distributed locks, caching, and locking decorators at hand
5
- Home-page: https://github.com/EzyGang/py-cachify
6
- License: MIT
7
- Author: Galtozzy
8
- Author-email: galtozzy+git@gmail.com
9
- Requires-Python: >=3.8,<4.0
5
+ Project-URL: Homepage, https://github.com/EzyGang/py-cachify
6
+ Project-URL: Repository, https://github.com/EzyGang/py-cachify
7
+ Author-email: Galtozzy <galtozzy+git@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Intended Audience :: Information Technology
@@ -15,19 +15,19 @@ Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Operating System :: OS Independent
16
16
  Classifier: Programming Language :: Python
17
17
  Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
18
19
  Classifier: Programming Language :: Python :: 3.8
19
20
  Classifier: Programming Language :: Python :: 3.9
20
21
  Classifier: Programming Language :: Python :: 3.10
21
22
  Classifier: Programming Language :: Python :: 3.11
22
23
  Classifier: Programming Language :: Python :: 3.12
23
- Classifier: Programming Language :: Python :: 3 :: Only
24
24
  Classifier: Programming Language :: Python :: 3.13
25
25
  Classifier: Topic :: Software Development
26
26
  Classifier: Topic :: Software Development :: Libraries
27
27
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
28
  Classifier: Typing :: Typed
29
- Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
30
- Project-URL: Repository, https://github.com/EzyGang/py-cachify
29
+ Requires-Python: <4.0,>=3.8
30
+ Requires-Dist: typing-extensions<5,>=4.12.2
31
31
  Description-Content-Type: text/markdown
32
32
 
33
33
  <p align="center">
@@ -220,4 +220,3 @@ If you'd like to contribute, please first discuss the changes using Issues, and
220
220
  ## License
221
221
 
222
222
  This project is licensed under the MIT License - see the [LICENSE](https://github.com/EzyGang/py-cachify/blob/main/LICENSE) file for details.
223
-
@@ -60,7 +60,9 @@ def cached(
60
60
  @wraps(_awaitable_func)
61
61
  async def _async_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
62
62
  cachify = get_cachify()
63
- _key = get_full_key_from_signature(bound_args=signature.bind(*args, **kwargs), key=key)
63
+ _key = get_full_key_from_signature(
64
+ bound_args=signature.bind(*args, **kwargs), key=key, operation_postfix='cached'
65
+ )
64
66
  if val := await cachify.a_get(key=_key):
65
67
  return cast(_R, encode_decode_value(encoder_decoder=dec, val=val))
66
68
 
@@ -68,7 +70,7 @@ def cached(
68
70
  await cachify.a_set(key=_key, val=encode_decode_value(encoder_decoder=enc, val=res), ttl=ttl)
69
71
  return res
70
72
 
71
- setattr(_async_wrapper, 'reset', partial(a_reset, signature=signature, key=key))
73
+ setattr(_async_wrapper, 'reset', partial(a_reset, signature=signature, key=key, operation_postfix='cached'))
72
74
 
73
75
  return cast(AsyncResetWrappedF[_P, _R], cast(object, _async_wrapper))
74
76
  else:
@@ -77,7 +79,9 @@ def cached(
77
79
  @wraps(_sync_func)
78
80
  def _sync_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
79
81
  cachify = get_cachify()
80
- _key = get_full_key_from_signature(bound_args=signature.bind(*args, **kwargs), key=key)
82
+ _key = get_full_key_from_signature(
83
+ bound_args=signature.bind(*args, **kwargs), key=key, operation_postfix='cached'
84
+ )
81
85
  if val := cachify.get(key=_key):
82
86
  return encode_decode_value(encoder_decoder=dec, val=val)
83
87
 
@@ -85,7 +89,7 @@ def cached(
85
89
  cachify.set(key=_key, val=encode_decode_value(encoder_decoder=enc, val=res), ttl=ttl)
86
90
  return res
87
91
 
88
- setattr(_sync_wrapper, 'reset', partial(reset, signature=signature, key=key))
92
+ setattr(_sync_wrapper, 'reset', partial(reset, signature=signature, key=key, operation_postfix='cached'))
89
93
 
90
94
  return cast(SyncResetWrappedF[_P, _R], cast(object, _sync_wrapper))
91
95
 
@@ -0,0 +1,4 @@
1
+ from typing import Literal
2
+
3
+
4
+ OperationPostfix = Literal['once', 'cached', 'lock']
@@ -4,6 +4,7 @@ from typing import Any, Awaitable, Callable, Dict, Tuple, TypeVar, Union
4
4
 
5
5
  from typing_extensions import ParamSpec, TypeIs
6
6
 
7
+ from ._constants import OperationPostfix
7
8
  from ._lib import get_cachify
8
9
  from ._types._common import Decoder, Encoder
9
10
 
@@ -13,7 +14,11 @@ _P = ParamSpec('_P')
13
14
  _S = TypeVar('_S')
14
15
 
15
16
 
16
- def get_full_key_from_signature(bound_args: inspect.BoundArguments, key: str) -> str:
17
+ def get_full_key_from_signature(
18
+ bound_args: inspect.BoundArguments,
19
+ key: str,
20
+ operation_postfix: OperationPostfix,
21
+ ) -> str:
17
22
  bound_args.apply_defaults()
18
23
  _args_repr = f'{bound_args}'
19
24
 
@@ -23,7 +28,7 @@ def get_full_key_from_signature(bound_args: inspect.BoundArguments, key: str) ->
23
28
  kwargs.update(args_dict)
24
29
 
25
30
  try:
26
- return key.format(*args, **kwargs)
31
+ return f'{key.format(*args, **kwargs)}-{operation_postfix}'
27
32
  except (IndexError, KeyError):
28
33
  raise ValueError(f'Arguments in a key({key}) do not match function signature params({_args_repr})') from None
29
34
 
@@ -41,33 +46,49 @@ def encode_decode_value(encoder_decoder: Union[Encoder, Decoder, None], val: Any
41
46
  return encoder_decoder(val)
42
47
 
43
48
 
44
- def reset(*args: Any, key: str, signature: inspect.Signature, **kwargs: Any) -> None:
49
+ def reset(
50
+ *args: Any, key: str, signature: inspect.Signature, operation_postfix: OperationPostfix, **kwargs: Any
51
+ ) -> None:
45
52
  cachify = get_cachify()
46
- _key = get_full_key_from_signature(bound_args=signature.bind(*args, **kwargs), key=key)
53
+ _key = get_full_key_from_signature(
54
+ bound_args=signature.bind(*args, **kwargs), key=key, operation_postfix=operation_postfix
55
+ )
47
56
 
48
57
  cachify.delete(key=_key)
49
58
 
50
59
  return None
51
60
 
52
61
 
53
- async def a_reset(*args: Any, key: str, signature: inspect.Signature, **kwargs: Any) -> None:
62
+ async def a_reset(
63
+ *args: Any, key: str, signature: inspect.Signature, operation_postfix: OperationPostfix, **kwargs: Any
64
+ ) -> None:
54
65
  cachify = get_cachify()
55
- _key = get_full_key_from_signature(bound_args=signature.bind(*args, **kwargs), key=key)
66
+ _key = get_full_key_from_signature(
67
+ bound_args=signature.bind(*args, **kwargs), key=key, operation_postfix=operation_postfix
68
+ )
56
69
 
57
70
  await cachify.a_delete(key=_key)
58
71
 
59
72
  return None
60
73
 
61
74
 
62
- async def is_alocked(*args: Any, key: str, signature: inspect.Signature, **kwargs: Any) -> bool:
75
+ async def is_alocked(
76
+ *args: Any, key: str, signature: inspect.Signature, operation_postfix: OperationPostfix, **kwargs: Any
77
+ ) -> bool:
63
78
  cachify = get_cachify()
64
- _key = get_full_key_from_signature(bound_args=signature.bind(*args, **kwargs), key=key)
79
+ _key = get_full_key_from_signature(
80
+ bound_args=signature.bind(*args, **kwargs), key=key, operation_postfix=operation_postfix
81
+ )
65
82
 
66
83
  return bool(await cachify.a_get(key=_key))
67
84
 
68
85
 
69
- def is_locked(*args: Any, key: str, signature: inspect.Signature, **kwargs: Any) -> bool:
86
+ def is_locked(
87
+ *args: Any, key: str, signature: inspect.Signature, operation_postfix: OperationPostfix, **kwargs: Any
88
+ ) -> bool:
70
89
  cachify = get_cachify()
71
- _key = get_full_key_from_signature(bound_args=signature.bind(*args, **kwargs), key=key)
90
+ _key = get_full_key_from_signature(
91
+ bound_args=signature.bind(*args, **kwargs), key=key, operation_postfix=operation_postfix
92
+ )
72
93
 
73
94
  return bool(cachify.get(key=_key))
@@ -1,15 +1,15 @@
1
1
  import inspect
2
- import logging
3
2
  import time
4
3
  from asyncio import sleep as asleep
5
4
  from functools import partial, wraps
6
5
  from typing import TYPE_CHECKING, Any, Awaitable, Callable, Optional, TypeVar, Union, cast
7
6
 
8
- from typing_extensions import ParamSpec, Self, deprecated, overload, override
7
+ from typing_extensions import ParamSpec, Self, deprecated, final, overload, override
9
8
 
10
9
  from ._exceptions import CachifyLockError
11
10
  from ._helpers import a_reset, get_full_key_from_signature, is_alocked, is_coroutine, is_locked, reset
12
11
  from ._lib import get_cachify
12
+ from ._logger import logger
13
13
  from ._types._common import UNSET, LockProtocolBase, UnsetType
14
14
  from ._types._lock_wrap import AsyncLockWrappedF, SyncLockWrappedF, WrappedFunctionLock
15
15
 
@@ -18,7 +18,6 @@ if TYPE_CHECKING:
18
18
  from ._lib import Cachify
19
19
 
20
20
 
21
- logger = logging.getLogger(__name__)
22
21
  _R = TypeVar('_R', covariant=True)
23
22
  _P = ParamSpec('_P')
24
23
  _S = TypeVar('_S')
@@ -93,6 +92,7 @@ class SyncLockMethods(LockProtocolBase):
93
92
  self.release()
94
93
 
95
94
 
95
+ @final
96
96
  class lock(AsyncLockMethods, SyncLockMethods):
97
97
  """
98
98
  Class to manage locking mechanism for synchronous and asynchronous functions.
@@ -155,7 +155,7 @@ class lock(AsyncLockMethods, SyncLockMethods):
155
155
  @wraps(_awaitable_func)
156
156
  async def _async_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
157
157
  bound_args = signature.bind(*args, **kwargs)
158
- _key = get_full_key_from_signature(bound_args=bound_args, key=self._key)
158
+ _key = get_full_key_from_signature(bound_args=bound_args, key=self._key, operation_postfix='lock')
159
159
 
160
160
  async with lock(
161
161
  key=_key,
@@ -165,8 +165,16 @@ class lock(AsyncLockMethods, SyncLockMethods):
165
165
  ):
166
166
  return await _awaitable_func(*args, **kwargs)
167
167
 
168
- setattr(_async_wrapper, 'is_locked', partial(is_alocked, signature=signature, key=self._key))
169
- setattr(_async_wrapper, 'release', partial(a_reset, signature=signature, key=self._key))
168
+ setattr(
169
+ _async_wrapper,
170
+ 'is_locked',
171
+ partial(is_alocked, signature=signature, key=self._key, operation_postfix='lock'),
172
+ )
173
+ setattr(
174
+ _async_wrapper,
175
+ 'release',
176
+ partial(a_reset, signature=signature, key=self._key, operation_postfix='lock'),
177
+ )
170
178
 
171
179
  return cast(AsyncLockWrappedF[_P, _R], cast(object, _async_wrapper))
172
180
  else:
@@ -175,13 +183,19 @@ class lock(AsyncLockMethods, SyncLockMethods):
175
183
  @wraps(_sync_func)
176
184
  def _sync_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
177
185
  bound_args = signature.bind(*args, **kwargs)
178
- _key = get_full_key_from_signature(bound_args=bound_args, key=self._key)
186
+ _key = get_full_key_from_signature(bound_args=bound_args, key=self._key, operation_postfix='lock')
179
187
 
180
188
  with lock(key=_key, nowait=self._nowait, timeout=self._timeout, exp=self._exp):
181
189
  return _sync_func(*args, **kwargs)
182
190
 
183
- setattr(_sync_wrapper, 'is_locked', partial(is_locked, signature=signature, key=self._key))
184
- setattr(_sync_wrapper, 'release', partial(reset, signature=signature, key=self._key))
191
+ setattr(
192
+ _sync_wrapper,
193
+ 'is_locked',
194
+ partial(is_locked, signature=signature, key=self._key, operation_postfix='lock'),
195
+ )
196
+ setattr(
197
+ _sync_wrapper, 'release', partial(reset, signature=signature, key=self._key, operation_postfix='lock')
198
+ )
185
199
 
186
200
  return cast(SyncLockWrappedF[_P, _R], cast(object, _sync_wrapper))
187
201
 
@@ -210,7 +224,7 @@ class lock(AsyncLockMethods, SyncLockMethods):
210
224
  msg = f'{key} is already locked!'
211
225
 
212
226
  if do_log:
213
- logger.warning(msg)
227
+ logger.debug(msg)
214
228
 
215
229
  if do_raise:
216
230
  raise CachifyLockError(msg)
@@ -254,7 +268,7 @@ def once(key: str, raise_on_locked: bool = False, return_on_locked: Any = None)
254
268
  @wraps(_awaitable_func)
255
269
  async def _async_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
256
270
  bound_args = signature.bind(*args, **kwargs)
257
- _key = get_full_key_from_signature(bound_args=bound_args, key=key)
271
+ _key = get_full_key_from_signature(bound_args=bound_args, key=key, operation_postfix='once')
258
272
 
259
273
  try:
260
274
  async with lock(key=_key):
@@ -265,8 +279,10 @@ def once(key: str, raise_on_locked: bool = False, return_on_locked: Any = None)
265
279
 
266
280
  return return_on_locked # type: ignore[no-any-return]
267
281
 
268
- setattr(_async_wrapper, 'release', partial(a_reset, signature=signature, key=key))
269
- setattr(_async_wrapper, 'is_locked', partial(is_alocked, signature=signature, key=key))
282
+ setattr(_async_wrapper, 'release', partial(a_reset, signature=signature, key=key, operation_postfix='once'))
283
+ setattr(
284
+ _async_wrapper, 'is_locked', partial(is_alocked, signature=signature, key=key, operation_postfix='once')
285
+ )
270
286
 
271
287
  return cast(AsyncLockWrappedF[_P, _R], cast(object, _async_wrapper))
272
288
 
@@ -276,7 +292,7 @@ def once(key: str, raise_on_locked: bool = False, return_on_locked: Any = None)
276
292
  @wraps(_sync_func)
277
293
  def _sync_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
278
294
  bound_args = signature.bind(*args, **kwargs)
279
- _key = get_full_key_from_signature(bound_args=bound_args, key=key)
295
+ _key = get_full_key_from_signature(bound_args=bound_args, key=key, operation_postfix='once')
280
296
 
281
297
  try:
282
298
  with lock(key=_key):
@@ -287,8 +303,10 @@ def once(key: str, raise_on_locked: bool = False, return_on_locked: Any = None)
287
303
 
288
304
  return return_on_locked
289
305
 
290
- setattr(_sync_wrapper, 'release', partial(reset, signature=signature, key=key))
291
- setattr(_sync_wrapper, 'is_locked', partial(is_locked, signature=signature, key=key))
306
+ setattr(_sync_wrapper, 'release', partial(reset, signature=signature, key=key, operation_postfix='once'))
307
+ setattr(
308
+ _sync_wrapper, 'is_locked', partial(is_locked, signature=signature, key=key, operation_postfix='once')
309
+ )
292
310
 
293
311
  return cast(SyncLockWrappedF[_P, _R], cast(object, _sync_wrapper))
294
312
 
@@ -0,0 +1,4 @@
1
+ import logging
2
+
3
+
4
+ logger = logging.getLogger('py-cachify')
@@ -1,13 +1,11 @@
1
- [tool.poetry]
1
+ [project]
2
2
  name = "py-cachify"
3
- version = "2.0.9"
4
- homepage = "https://github.com/EzyGang/py-cachify"
5
- repository = "https://github.com/EzyGang/py-cachify"
6
- license = "MIT"
3
+ version = "2.1.0"
7
4
  description = "Distributed locks, caching, and locking decorators at hand"
8
- authors = ["Galtozzy <galtozzy+git@gmail.com>"]
5
+ authors = [{ name = "Galtozzy", email = "galtozzy+git@gmail.com" }]
6
+ requires-python = ">=3.8,<4.0"
9
7
  readme = "README.md"
10
- include = ["README.md"]
8
+ license = "MIT"
11
9
  classifiers = [
12
10
  "Intended Audience :: Information Technology",
13
11
  "Intended Audience :: System Administrators",
@@ -29,40 +27,57 @@ classifiers = [
29
27
  "Programming Language :: Python :: 3.13",
30
28
  "License :: OSI Approved :: MIT License",
31
29
  ]
32
- packages = [
33
- { include = 'py_cachify' },
34
- { include = 'py_cachify/py.typed'},
35
- ]
30
+ dependencies = ["typing-extensions>=4.12.2,<5"]
36
31
 
37
- [project]
38
- requires-python = ">=3.8,<4.0"
39
-
40
- [tool.poetry.dependencies]
41
- python = "^3.8"
42
- typing-extensions = "^4.12.2"
43
-
44
- [tool.poetry.group.dev.dependencies]
45
- pytest = "^8.3.2"
46
- pytest-mock = "^3.14.0"
47
- pytest-cov = "^5.0.0"
48
- taskipy = "^1.13.0"
49
- mypy = "^1.11.1"
50
- coverage = "^7.6.1"
51
- pytest-asyncio = "^0.24.0"
52
- pytest-socket = "^0.7.0"
53
- ruff = ">=0.7.1,<0.9.0"
32
+ [project.urls]
33
+ Homepage = "https://github.com/EzyGang/py-cachify"
34
+ Repository = "https://github.com/EzyGang/py-cachify"
54
35
 
36
+ [build-system]
37
+ requires = ["hatchling"]
38
+ build-backend = "hatchling.build"
39
+
40
+ [dependency-groups]
41
+ dev = [
42
+ "pytest>=8.3.2,<9",
43
+ "pytest-mock>=3.14.0,<4",
44
+ "pytest-cov>=5.0.0,<6",
45
+ "taskipy>=1.13.0,<2",
46
+ "mypy>=1.11.1,<2",
47
+ "coverage>=7.6.1,<8",
48
+ "pytest-asyncio>=0.24.0,<0.25",
49
+ "pytest-socket>=0.7.0,<0.8",
50
+ "ruff>=0.9.2,<0.10",
51
+ ]
52
+ docs = [
53
+ "mkdocs>=1.6.0,<2",
54
+ "mkdocs-material>=9.5.28,<10",
55
+ "pygments>=2.18.0,<3",
56
+ "termynal>=0.12.1,<0.13 ; python_version >= '3.8.1' and python_version < '4.0'",
57
+ "beautifulsoup4>=4.12.3,<5",
58
+ ]
59
+ integration = ["redis>=5.0.7,<6"]
55
60
 
56
- [tool.poetry.group.docs.dependencies]
57
- mkdocs = "^1.6.0"
58
- mkdocs-material = "^9.5.28"
59
- pygments = "^2.18.0"
60
- termynal = { version = "^0.12.1", python = ">=3.8.1,<4.0" }
61
- beautifulsoup4 = "^4.12.3"
61
+ [tool.uv]
62
+ default-groups = [
63
+ "dev",
64
+ "docs",
65
+ "integration",
66
+ ]
62
67
 
68
+ [tool.hatch.build.targets.sdist]
69
+ include = [
70
+ "py_cachify",
71
+ "py_cachify/py.typed",
72
+ "README.md",
73
+ ]
63
74
 
64
- [tool.poetry.group.integration.dependencies]
65
- redis = "^5.0.7"
75
+ [tool.hatch.build.targets.wheel]
76
+ include = [
77
+ "py_cachify",
78
+ "py_cachify/py.typed",
79
+ "README.md",
80
+ ]
66
81
 
67
82
  [tool.taskipy.tasks]
68
83
  format-and-lint = "task ruff && task mypy-lint"
@@ -82,7 +97,6 @@ line-length = 120
82
97
  extend-exclude = ["site-packages", "*.pyi"]
83
98
  target-version = 'py38'
84
99
 
85
-
86
100
  [tool.ruff.lint]
87
101
  fixable = ["ALL"]
88
102
  unfixable = []
@@ -131,7 +145,6 @@ exclude = ['test_']
131
145
  module = "tests.*"
132
146
  ignore_errors = true
133
147
 
134
-
135
148
  [tool.pytest.ini_options]
136
149
  minversion = "6.0"
137
150
  addopts = [
@@ -158,7 +171,6 @@ testpaths = ["tests"]
158
171
  omit = []
159
172
  concurrency = ['thread']
160
173
 
161
-
162
174
  [tool.coverage.report]
163
175
  omit = []
164
176
  exclude_lines = [
@@ -172,8 +184,5 @@ exclude_lines = [
172
184
  'if __name__ == .__main__.:',
173
185
  '__all__',
174
186
  'if TYPE_CHECKING:',
187
+ 'except ModuleNotFoundError:',
175
188
  ]
176
-
177
- [build-system]
178
- requires = ["poetry-core"]
179
- build-backend = "poetry.core.masonry.api"
File without changes