limits 5.6.0__py3-none-any.whl → 5.7.0__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.
limits/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '5.6.0'
32
- __version_tuple__ = version_tuple = (5, 6, 0)
31
+ __version__ = version = '5.7.0'
32
+ __version_tuple__ = version_tuple = (5, 7, 0)
33
33
 
34
34
  __commit_id__ = commit_id = None
limits/storage/mongodb.py CHANGED
@@ -156,34 +156,34 @@ class MongoDBStorageBase(
156
156
  seconds=expiry
157
157
  )
158
158
 
159
- return int(
160
- self.counters.find_one_and_update(
161
- {"_id": key},
162
- [
163
- {
164
- "$set": {
165
- "count": {
166
- "$cond": {
167
- "if": {"$lt": ["$expireAt", "$$NOW"]},
168
- "then": amount,
169
- "else": {"$add": ["$count", amount]},
170
- }
171
- },
172
- "expireAt": {
173
- "$cond": {
174
- "if": {"$lt": ["$expireAt", "$$NOW"]},
175
- "then": expiration,
176
- "else": "$expireAt",
177
- }
178
- },
179
- }
180
- },
181
- ],
182
- upsert=True,
183
- projection=["count"],
184
- return_document=self.lib.ReturnDocument.AFTER,
185
- )["count"]
186
- )
159
+ if response := self.counters.find_one_and_update(
160
+ {"_id": key},
161
+ [
162
+ {
163
+ "$set": {
164
+ "count": {
165
+ "$cond": {
166
+ "if": {"$lt": ["$expireAt", "$$NOW"]},
167
+ "then": amount,
168
+ "else": {"$add": ["$count", amount]},
169
+ }
170
+ },
171
+ "expireAt": {
172
+ "$cond": {
173
+ "if": {"$lt": ["$expireAt", "$$NOW"]},
174
+ "then": expiration,
175
+ "else": "$expireAt",
176
+ }
177
+ },
178
+ }
179
+ },
180
+ ],
181
+ upsert=True,
182
+ projection=["count"],
183
+ return_document=self.lib.ReturnDocument.AFTER,
184
+ ):
185
+ return int(response["count"])
186
+ return 0
187
187
 
188
188
  def check(self) -> bool:
189
189
  """
@@ -468,7 +468,7 @@ class MongoDBStorageBase(
468
468
  return_document=self.lib.ReturnDocument.AFTER,
469
469
  upsert=True,
470
470
  )
471
- return cast(bool, result["_acquired"])
471
+ return cast(bool, result["_acquired"] if result else False)
472
472
 
473
473
  def clear_sliding_window(self, key: str, expiry: int) -> None:
474
474
  return self.clear(key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: limits
3
- Version: 5.6.0
3
+ Version: 5.7.0
4
4
  Summary: Rate limiting utilities
5
5
  Project-URL: Homepage, https://limits.readthedocs.org
6
6
  Project-URL: Source, https://github.com/alisaifee/limits
@@ -19,6 +19,7 @@ Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
22
23
  Classifier: Programming Language :: Python :: Implementation :: PyPy
23
24
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
25
  Requires-Python: >=3.10
@@ -38,7 +39,7 @@ Requires-Dist: pymemcache<5.0.0,>3; extra == 'memcached'
38
39
  Provides-Extra: mongodb
39
40
  Requires-Dist: pymongo<5,>4.1; extra == 'mongodb'
40
41
  Provides-Extra: redis
41
- Requires-Dist: redis!=4.5.2,!=4.5.3,<7.0.0,>3; extra == 'redis'
42
+ Requires-Dist: redis!=4.5.2,!=4.5.3,<8.0.0,>3; extra == 'redis'
42
43
  Provides-Extra: rediscluster
43
44
  Requires-Dist: redis!=4.5.2,!=4.5.3,>=4.2.0; extra == 'rediscluster'
44
45
  Provides-Extra: valkey
@@ -1,5 +1,5 @@
1
1
  limits/__init__.py,sha256=o797RFCrvTx-9XGu8tsQYH5ZOtX-UVh6xwq_eatc_AU,734
2
- limits/_version.py,sha256=3ucixGE1aqqT6_wVh9iJlYsogjPN83_jiyXCqsGzfqU,704
2
+ limits/_version.py,sha256=k_RD_hW7ZrSTC0fqTWaif1G2YcUxmgQW3auzaKG5Wdg,704
3
3
  limits/_version.pyi,sha256=Y25n44pyE3vp92MiABKrcK3IWRyQ1JG1rZ4Ufqy2nC0,17
4
4
  limits/errors.py,sha256=s1el9Vg0ly-z92guvnvYNgKi3_aVqpiw_sufemiLLTI,662
5
5
  limits/limits.py,sha256=EztiGCXBVwIqNtps77HiW6vLlMO93wCh7mu5W7BuhwI,5011
@@ -32,12 +32,12 @@ limits/storage/__init__.py,sha256=9iNxIlwzLQw2d54EcMa2LBJ47wiWCPOnHgn6ddqKkDI,26
32
32
  limits/storage/base.py,sha256=QFVhOS8VdR7PDhaYMSc77SLg8yaGm0PCNNrMu4ZamfY,7264
33
33
  limits/storage/memcached.py,sha256=AzT3vz-MnkFxS0mF3C0QjGPzCnmUt29qTnuOKhKVKYI,10455
34
34
  limits/storage/memory.py,sha256=4W8hWIEzwQpoh1z0LcfwuP6DqeFoVuOEM2u8WpZkfdQ,8957
35
- limits/storage/mongodb.py,sha256=Cg_Vj33N7Ozxdmq7RGMCerg1XuVOhRAU7eusfhiSZBc,18170
35
+ limits/storage/mongodb.py,sha256=a-KX1H-0DafEwWzwTmcqJ9YuMyAwg1R-JfkTEiBJ0pQ,18123
36
36
  limits/storage/redis.py,sha256=zTwxV5qosxGBTrkZmD4UWQdvavDbWpYHXY7H3hXH-Sw,10791
37
37
  limits/storage/redis_cluster.py,sha256=GkL8GCQFfxDriMzsPMkaj6pMEX5FvQXYpUtXLY5q8fQ,4621
38
38
  limits/storage/redis_sentinel.py,sha256=OSb61DxgUxMgXSIjaM_pF5-entD8XntD56xt0rFu89k,4479
39
39
  limits/storage/registry.py,sha256=CxSaDBGR5aBJPFAIsfX9axCnbcThN3Bu-EH4wHrXtu8,650
40
- limits-5.6.0.dist-info/METADATA,sha256=AnwByiIGfXg-bL9FEzNEZ82RG2OXhbzkCMds8DZtob4,10357
41
- limits-5.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
42
- limits-5.6.0.dist-info/licenses/LICENSE.txt,sha256=T6i7kq7F5gIPfcno9FCxU5Hcwm22Bjq0uHZV3ElcjsQ,1061
43
- limits-5.6.0.dist-info/RECORD,,
40
+ limits-5.7.0.dist-info/METADATA,sha256=UxFo4RjIABUC1vbmniJlq8wc3xX1PIMot3rVbgYm6h0,10408
41
+ limits-5.7.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
42
+ limits-5.7.0.dist-info/licenses/LICENSE.txt,sha256=T6i7kq7F5gIPfcno9FCxU5Hcwm22Bjq0uHZV3ElcjsQ,1061
43
+ limits-5.7.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any