Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4fe109e

Browse filesBrowse files
committed
Replaced cache decorator to extend python version support
1 parent b2c276b commit 4fe109e
Copy full SHA for 4fe109e

File tree

Expand file treeCollapse file tree

2 files changed

+11
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-2
lines changed

‎tempmail/__init__.py

Copy file name to clipboardExpand all lines: tempmail/__init__.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import time
1616
import random
17-
from functools import cache
1817

1918
import requests
2019

@@ -35,7 +34,7 @@
3534
"""List of allowed email domains"""
3635

3736

38-
@cache
37+
@utils.cache
3938
def _check_message(email: str, id: int, filter: callable) -> tuple[bool, dict[str, any]]:
4039
"""Check if a message matches the filter"""
4140
message = get_message(email, id)

‎tempmail/utils.py

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import random
22
import string
3+
import functools
34

45

56
def random_string(length: int):
67
return ''.join(random.choices(string.ascii_lowercase, k=length))
8+
9+
10+
def cache(func):
11+
"""Cache the result of a function with saved type hints"""
12+
@functools.lru_cache
13+
@functools.wraps(func)
14+
def wrapper(*args, **kwargs):
15+
return func(*args, **kwargs)
16+
return wrapper

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.