Skip to content

Commit 537389f

Browse files
authored
Merge pull request #5 from cubicbyte/python-3.7-support
Add python 3.7+ support
2 parents a2da524 + 2ba7b08 commit 537389f

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Python Temp Email Library
2+
3+
[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads)
4+
25
**tempmail-python** is a Python library for generating and managing temporary email addresses using the 1secmail service. It provides functions for creating email addresses, checking for new messages, and retrieving message contents.
36

47
## Installation

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from setuptools import setup, find_packages
22

3+
34
def read(path: str) -> str:
45
with open(path, 'r', encoding='utf-8') as f:
56
return f.read()
67

8+
79
setup(
810
name='tempmail-python',
911
version='2.3.2',
@@ -13,15 +15,16 @@ def read(path: str) -> str:
1315
author='cubicbyte',
1416
author_email='bmaruhnenko@gmail.com',
1517
url='https://github.com/cubicbyte/tempmail-python',
16-
packages = find_packages(),
18+
packages=find_packages(),
1719
license='MIT',
1820
keywords='disposable-email temporary-email temp-email temp-mail email mail email-generator mail-generator',
1921
install_requires=[
2022
'requests>=2.19.0',
2123
],
24+
python_requires='>=3.7',
2225
classifiers=[
2326
'Development Status :: 5 - Production/Stable',
2427
'Programming Language :: Python :: 3',
2528
'License :: OSI Approved :: MIT License',
2629
],
27-
)
30+
)

tempmail/providers.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import time
22
import random
3+
from typing import Dict, Optional, Tuple, List, Callable
34
from datetime import datetime
45
from dataclasses import dataclass
5-
from typing import Optional, List, Tuple, Dict
66

77
import requests
88

99
from . import utils
1010

11-
__all__ = ('OneSecMail',)
11+
__all__ = (
12+
'OneSecMail',
13+
)
1214

1315

1416
class OneSecMail:
@@ -17,7 +19,12 @@ class OneSecMail:
1719
inbox_update_interval = 0.5
1820
"""How often to update the inbox in seconds"""
1921

20-
def __init__(self, address: Optional[str] = None, username: Optional[str] = None, domain: Optional[str] = None) -> None:
22+
def __init__(
23+
self,
24+
address: Optional[str] = None,
25+
username: Optional[str] = None,
26+
domain: Optional[str] = None,
27+
) -> None:
2128
"""Create a new 1secmail.com email address
2229
2330
:param address: The full email address (username@domain)
@@ -57,7 +64,8 @@ def download_attachment(self, id: int, file: str) -> bytes:
5764
resp.raise_for_status()
5865
return resp.content
5966

60-
def wait_for_message(self, timeout: Optional[int] = 60, filter: callable = lambda _: True) -> 'OneSecMail.Message':
67+
def wait_for_message(self, timeout: Optional[int] = 60,
68+
filter: Callable[['OneSecMail.Message'], bool] = lambda _: True) -> 'OneSecMail.Message':
6169
"""Wait for a message to arrive in the inbox
6270
6371
:param timeout: How long to wait for a message to arrive, in seconds
@@ -148,7 +156,7 @@ class Message:
148156
html_body: str
149157
"Message body (html format)"
150158
_mail_instance: 'OneSecMail'
151-
_attachments: list[dict[str, any]]
159+
_attachments: List[Dict[str, any]]
152160

153161
@property
154162
def date(self) -> datetime:
@@ -158,7 +166,8 @@ def date(self) -> datetime:
158166
@property
159167
def attachments(self) -> List['OneSecMail.Attachment']:
160168
"""List of attachments in the message (files)"""
161-
return [OneSecMail.Attachment.from_dict(self._mail_instance, self.id, attachment) for attachment in self._attachments]
169+
return [OneSecMail.Attachment.from_dict(self._mail_instance, self.id, attachment)
170+
for attachment in self._attachments]
162171

163172
@classmethod
164173
def from_dict(cls, mail_instance: 'OneSecMail', msg: Dict[str, any]) -> 'OneSecMail.Message':

tempmail/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def random_string(length: int):
1111

1212
def cache(func):
1313
"""Cache the result of a function with saved type hints"""
14-
@functools.lru_cache
14+
@functools.lru_cache(maxsize=128)
1515
@functools.wraps(func)
1616
def wrapper(*args, **kwargs):
1717
return func(*args, **kwargs)

0 commit comments

Comments
 (0)