limits 3.10.1__py3-none-any.whl → 3.11.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
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-03-17T11:35:51-0700",
11
+ "date": "2024-04-20T13:09:37-0700",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "cf7f1e273700987e38e2af734719253785a303b0",
15
- "version": "3.10.1"
14
+ "full-revisionid": "0a1a9c70cbffe4c51a5f34500fe4edfe342de638",
15
+ "version": "3.11.0"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -116,7 +116,11 @@ class MongoDBStorage(Storage, MovingWindowSupport):
116
116
  :param key: the key to get the expiry for
117
117
  """
118
118
  counter = await self.database.counters.find_one({"_id": key})
119
- expiry = counter["expireAt"] if counter else datetime.datetime.utcnow()
119
+ expiry = (
120
+ counter["expireAt"]
121
+ if counter
122
+ else datetime.datetime.now(datetime.timezone.utc)
123
+ )
120
124
 
121
125
  return calendar.timegm(expiry.timetuple())
122
126
 
@@ -125,7 +129,10 @@ class MongoDBStorage(Storage, MovingWindowSupport):
125
129
  :param key: the key to get the counter value for
126
130
  """
127
131
  counter = await self.database.counters.find_one(
128
- {"_id": key, "expireAt": {"$gte": datetime.datetime.utcnow()}},
132
+ {
133
+ "_id": key,
134
+ "expireAt": {"$gte": datetime.datetime.now(datetime.timezone.utc)},
135
+ },
129
136
  projection=["count"],
130
137
  )
131
138
 
@@ -145,7 +152,9 @@ class MongoDBStorage(Storage, MovingWindowSupport):
145
152
  """
146
153
  await self.create_indices()
147
154
 
148
- expiration = datetime.datetime.utcnow() + datetime.timedelta(seconds=expiry)
155
+ expiration = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
156
+ seconds=expiry
157
+ )
149
158
 
150
159
  response = await self.database.counters.find_one_and_update(
151
160
  {"_id": key},
@@ -252,7 +261,8 @@ class MongoDBStorage(Storage, MovingWindowSupport):
252
261
 
253
262
  updates["$set"] = {
254
263
  "expireAt": (
255
- datetime.datetime.utcnow() + datetime.timedelta(seconds=expiry)
264
+ datetime.datetime.now(datetime.timezone.utc)
265
+ + datetime.timedelta(seconds=expiry)
256
266
  )
257
267
  }
258
268
  updates["$push"]["entries"]["$each"] = [timestamp] * amount
limits/storage/mongodb.py CHANGED
@@ -91,7 +91,11 @@ class MongoDBStorage(Storage, MovingWindowSupport):
91
91
  :param key: the key to get the expiry for
92
92
  """
93
93
  counter = self.counters.find_one({"_id": key})
94
- expiry = counter["expireAt"] if counter else datetime.datetime.utcnow()
94
+ expiry = (
95
+ counter["expireAt"]
96
+ if counter
97
+ else datetime.datetime.now(datetime.timezone.utc)
98
+ )
95
99
 
96
100
  return calendar.timegm(expiry.timetuple())
97
101
 
@@ -100,7 +104,10 @@ class MongoDBStorage(Storage, MovingWindowSupport):
100
104
  :param key: the key to get the counter value for
101
105
  """
102
106
  counter = self.counters.find_one(
103
- {"_id": key, "expireAt": {"$gte": datetime.datetime.utcnow()}},
107
+ {
108
+ "_id": key,
109
+ "expireAt": {"$gte": datetime.datetime.now(datetime.timezone.utc)},
110
+ },
104
111
  projection=["count"],
105
112
  )
106
113
 
@@ -116,7 +123,9 @@ class MongoDBStorage(Storage, MovingWindowSupport):
116
123
  :param expiry: amount in seconds for the key to expire in
117
124
  :param amount: the number to increment by
118
125
  """
119
- expiration = datetime.datetime.utcnow() + datetime.timedelta(seconds=expiry)
126
+ expiration = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
127
+ seconds=expiry
128
+ )
120
129
 
121
130
  return int(
122
131
  self.counters.find_one_and_update(
@@ -220,7 +229,8 @@ class MongoDBStorage(Storage, MovingWindowSupport):
220
229
 
221
230
  updates["$set"] = {
222
231
  "expireAt": (
223
- datetime.datetime.utcnow() + datetime.timedelta(seconds=expiry)
232
+ datetime.datetime.now(datetime.timezone.utc)
233
+ + datetime.timedelta(seconds=expiry)
224
234
  )
225
235
  }
226
236
  updates["$push"]["entries"]["$each"] = [timestamp] * amount
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: limits
3
- Version: 3.10.1
3
+ Version: 3.11.0
4
4
  Summary: Rate limiting utilities
5
5
  Home-page: https://limits.readthedocs.org
6
6
  Author: Ali-Akber Saifee
@@ -18,8 +18,9 @@ Classifier: Programming Language :: Python :: 3.8
18
18
  Classifier: Programming Language :: Python :: 3.9
19
19
  Classifier: Programming Language :: Python :: 3.10
20
20
  Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
21
22
  Classifier: Programming Language :: Python :: Implementation :: PyPy
22
- Requires-Python: >=3.7
23
+ Requires-Python: >=3.8
23
24
  License-File: LICENSE.txt
24
25
  Requires-Dist: deprecated >=1.2
25
26
  Requires-Dist: importlib-resources >=1.3
@@ -1,5 +1,5 @@
1
1
  limits/__init__.py,sha256=j_yVhgN9pdz8o5rQjVwdJTBSq8F-CTzof9kkiYgjRbw,728
2
- limits/_version.py,sha256=PvRq5kmAeA-fueZ3szG1C22nkUmb9GSWeeUdlNI0Q0Q,498
2
+ limits/_version.py,sha256=Z21cgsnzdsN25H07XvnYYsi604fLfYVJ8JH9oJPPRzg,498
3
3
  limits/errors.py,sha256=xCKGOVJiD-g8FlsQQb17AW2pTUvalYSuizPpvEVoYJE,626
4
4
  limits/limits.py,sha256=ZsXESq2e1ji7c2ZKjSkIAasCjiLdjVLPUa9oah_I8U4,4943
5
5
  limits/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -14,7 +14,7 @@ limits/aio/storage/base.py,sha256=dSM39OguwdLdBIHaz98eWljHzxUfgcatweNSeo9d8OQ,47
14
14
  limits/aio/storage/etcd.py,sha256=Rjb_EYKFRr4F2Z6zvAPP9vQOyXJQHaju3VjxxUs75_c,4791
15
15
  limits/aio/storage/memcached.py,sha256=6aTlACfCtchdcZqoisnei0MOlCH7yLV9A1yCjOE5f9g,4802
16
16
  limits/aio/storage/memory.py,sha256=DlmWluqUwBUWQIQ6XZi-mPrb15vfzBhA4iAKhBELDnE,5856
17
- limits/aio/storage/mongodb.py,sha256=5Xm1oUbMQ9UjenE0s6o6Cdea35ntqWhEDUv6HEx79kQ,9183
17
+ limits/aio/storage/mongodb.py,sha256=sFQQK-JuInGEXC5Upjk_9NBe9hoNhgxQYimdRraXxQ8,9392
18
18
  limits/aio/storage/redis.py,sha256=jkqtdIwTpfXTXwgTWTA1Jlc3Lpc-vnu4XRy6CIptiZA,15651
19
19
  limits/resources/redis/lua_scripts/acquire_moving_window.lua,sha256=5CFJX7D6T6RG5SFr6eVZ6zepmI1EkGWmKeVEO4QNrWo,483
20
20
  limits/resources/redis/lua_scripts/clear_keys.lua,sha256=zU0cVfLGmapRQF9x9u0GclapM_IB2pJLszNzVQ1QRK4,184
@@ -25,13 +25,13 @@ limits/storage/base.py,sha256=fDdYLa-RrnjhBTO1hE5aTTM8q8n3M5HD-65KyWWXBtg,4627
25
25
  limits/storage/etcd.py,sha256=wkC_mj4Tsf2nwUKByMiHiGzA40N3mDepEwdLmvH8wmw,4484
26
26
  limits/storage/memcached.py,sha256=bMzfZgYa_EWcZAjSZLcygpk3hpeOAErBpRE8dVwyXQs,6640
27
27
  limits/storage/memory.py,sha256=R16E-Ccnmn1-LlolkFf-kB1-QHh8eiwFFLYVv0PuFD0,5561
28
- limits/storage/mongodb.py,sha256=U68bKPbEjkZJXwgyqI329Hph6ZBvPpMs54YKW15fZ6k,8079
28
+ limits/storage/mongodb.py,sha256=2YT0HFuQlAJHfES96nAT9c8nUsJp1WTxglTwgjdZ8DY,8288
29
29
  limits/storage/redis.py,sha256=3zJ1gDMDepT_pGN9d2aAN7Pea7tMBI49VK60IHv-Ooc,8452
30
30
  limits/storage/redis_cluster.py,sha256=KwhWV0v3_TliRyS3OU15IlpeC8gRQr29U4FkcME01fo,5380
31
31
  limits/storage/redis_sentinel.py,sha256=7PVB0hBl0I_enhN_h9QSJTE7zGuYtjkebotTqxm2iZo,3875
32
32
  limits/storage/registry.py,sha256=xcBcxuu6srqmoS4WqDpkCXnRLB19ctH98v21P8S9kS8,708
33
- limits-3.10.1.dist-info/LICENSE.txt,sha256=T6i7kq7F5gIPfcno9FCxU5Hcwm22Bjq0uHZV3ElcjsQ,1061
34
- limits-3.10.1.dist-info/METADATA,sha256=diqcU_qYhkekhZHIOLAcShrWhOqX4I2PM3c_qyrzzgM,7119
35
- limits-3.10.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
36
- limits-3.10.1.dist-info/top_level.txt,sha256=C7g5ahldPoU2s6iWTaJayUrbGmPK1d6e9t5Nn0vQ2jM,7
37
- limits-3.10.1.dist-info/RECORD,,
33
+ limits-3.11.0.dist-info/LICENSE.txt,sha256=T6i7kq7F5gIPfcno9FCxU5Hcwm22Bjq0uHZV3ElcjsQ,1061
34
+ limits-3.11.0.dist-info/METADATA,sha256=du5FUXrCT9NJbjfuQZ7LrCbsgjIBKCvn0AjRf1M6ovI,7170
35
+ limits-3.11.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
36
+ limits-3.11.0.dist-info/top_level.txt,sha256=C7g5ahldPoU2s6iWTaJayUrbGmPK1d6e9t5Nn0vQ2jM,7
37
+ limits-3.11.0.dist-info/RECORD,,