Skip to content

Commit

Permalink
Tweak typing hints
Browse files Browse the repository at this point in the history
  • Loading branch information
alisaifee committed Nov 28, 2021
1 parent 39c633e commit 0105492
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion limits/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

from abc import ABCMeta, abstractmethod
import weakref
from typing import Dict
from typing import Tuple
from typing import Type
from typing import Union

from .limits import RateLimitItem
from .storage import Storage
Expand Down Expand Up @@ -183,7 +186,13 @@ def hit(self, item: RateLimitItem, *identifiers) -> bool:
)


STRATEGIES = {
KnownStrategy = Union[
Type[FixedWindowRateLimiter],
Type[FixedWindowElasticExpiryRateLimiter],
Type[MovingWindowRateLimiter],
]

STRATEGIES: Dict[str, KnownStrategy] = {
"fixed-window": FixedWindowRateLimiter,
"fixed-window-elastic-expiry": FixedWindowElasticExpiryRateLimiter,
"moving-window": MovingWindowRateLimiter,
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
REQUIREMENTS = [
k

for k in open(os.path.join(THIS_DIR, "requirements", "main.txt"))
.read()
.splitlines()

if k.strip()
]

Expand All @@ -35,4 +37,7 @@
long_description=open("README.rst").read(),
packages=find_packages(exclude=["google.*", "google", "tests*"]),
python_requires=">3.7",
package_data={
"limits": ["py.typed"],
},
)

0 comments on commit 0105492

Please sign in to comment.