Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ jobs:
- "windows-latest"
- "macos-latest"
python:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
- "3.15"
include:
- python: "3.10"
tox-env: "py310"
- python: "3.11"
tox-env: "py311"
- python: "3.12"
tox-env: "py312"
- python: "3.13"
tox-env: "py313"
- python: "3.14"
tox-env: "py314"
- python: "3.15"
tox-env: "py315"
steps:
- uses: actions/checkout@v7
- name: Setup python
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
repos:
- repo: https://github.com/PyCQA/flake8
rev: 7.2.0
rev: 7.5.0
hooks:
- id: flake8
name: Style Guide Enforcement (flake8)
args:
- '--max-line-length=90'
- '--per-file-ignores=__init__.py:F401'
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
rev: v3.22.0
hooks:
- id: pyupgrade
name: Upgrade syntax for newer versions of the language (pyupgrade)
args:
- '--py39-plus'
- '--py311-plus'
- repo: https://github.com/pycqa/isort
rev: 6.0.1
rev: 9.0.2
hooks:
- id: isort
name: Reorder Python imports
Expand All @@ -27,13 +27,13 @@ repos:
# args:
# - '--in-place '
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v5.0.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-toml
- repo: https://github.com/python/black
rev: 25.1.0
rev: 26.10.1
hooks:
- id: black
name: Uncompromising Code Formatter (black)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Versions of this package up to 1.0.1 were different, unrelated project, that is

### Prerequisites

- Python version 3.10+
- Python version 3.11+

### Install package

Expand Down Expand Up @@ -335,7 +335,7 @@ To setup virtual environments, run tests and linters use:
tox
```

It will create virtual environments with all installed dependencies for each available python interpreter (starting from `python3.10`) on your machine.
It will create virtual environments with all installed dependencies for each available python interpreter (starting from `python3.11`) on your machine.
By default, they will be available in `{project}/.tox/` directory. So, for instance, to activate `python3.11` environment, run the following:

```bash
Expand Down
5 changes: 2 additions & 3 deletions examples/contacts/contact_fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import Optional

import mailtrap as mt
from mailtrap.models.common import DeletedObject
Expand Down Expand Up @@ -27,8 +26,8 @@ def create_contact_field(

def update_contact_field(
contact_field_id: int,
name: Optional[str] = None,
merge_tag: Optional[str] = None,
name: str | None = None,
merge_tag: str | None = None,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
) -> ContactField:
params = mt.UpdateContactFieldParams(name=name, merge_tag=merge_tag)
return contact_fields_api.update(contact_field_id, params)
Expand Down
16 changes: 7 additions & 9 deletions examples/contacts/contacts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
from typing import Optional
from typing import Union

import mailtrap as mt
from mailtrap.models.common import DeletedObject
Expand All @@ -15,8 +13,8 @@

def create_contact(
email: str,
fields: Optional[dict[str, Union[str, int, float, bool]]] = None,
list_ids: Optional[list[int]] = None,
fields: dict[str, str | int | float | bool] | None = None,
list_ids: list[int] | None = None,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
) -> Contact:
params = mt.CreateContactParams(
email=email,
Expand All @@ -28,11 +26,11 @@ def create_contact(

def update_contact(
contact_id_or_email: str,
new_email: Optional[str] = None,
fields: Optional[dict[str, Union[str, int, float, bool]]] = None,
list_ids_included: Optional[list[int]] = None,
list_ids_excluded: Optional[list[int]] = None,
unsubscribed: Optional[bool] = None,
new_email: str | None = None,
fields: dict[str, str | int | float | bool] | None = None,
list_ids_included: list[int] | None = None,
list_ids_excluded: list[int] | None = None,
unsubscribed: bool | None = None,
) -> Contact:
params = mt.UpdateContactParams(
email=new_email,
Expand Down
15 changes: 7 additions & 8 deletions examples/email_templates/templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import Optional

import mailtrap as mt
from mailtrap.models.common import DeletedObject
Expand All @@ -20,8 +19,8 @@ def create_template(
name: str,
subject: str,
category: str,
body_text: Optional[str] = None,
body_html: Optional[str] = None,
body_text: str | None = None,
body_html: str | None = None,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
) -> EmailTemplate:
params = mt.CreateEmailTemplateParams(
name=name,
Expand All @@ -39,11 +38,11 @@ def get_template(template_id: int) -> EmailTemplate:

def update_template(
template_id: int,
name: Optional[str] = None,
subject: Optional[str] = None,
category: Optional[str] = None,
body_text: Optional[str] = None,
body_html: Optional[str] = None,
name: str | None = None,
subject: str | None = None,
category: str | None = None,
body_text: str | None = None,
body_html: str | None = None,
) -> EmailTemplate:
params = mt.UpdateEmailTemplateParams(
name=name,
Expand Down
15 changes: 7 additions & 8 deletions examples/paginated_templates/templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import Optional

import mailtrap as mt
from mailtrap.models.common import DeletedObject
Expand All @@ -25,8 +24,8 @@ def create_template(
name: str,
subject: str,
category: str,
body_html: Optional[str] = None,
body_text: Optional[str] = None,
body_html: str | None = None,
body_text: str | None = None,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
) -> Template:
params = mt.CreateTemplateParams(
name=name,
Expand All @@ -44,11 +43,11 @@ def get_template(template_id: int) -> Template:

def update_template(
template_id: int,
name: Optional[str] = None,
subject: Optional[str] = None,
category: Optional[str] = None,
body_html: Optional[str] = None,
body_text: Optional[str] = None,
name: str | None = None,
subject: str | None = None,
category: str | None = None,
body_html: str | None = None,
body_text: str | None = None,
) -> Template:
params = mt.UpdateTemplateParams(
name=name,
Expand Down
7 changes: 3 additions & 4 deletions examples/sandbox/messages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from typing import Any
from typing import Optional

import mailtrap as mt
from mailtrap.models.messages import AnalysisReport
Expand Down Expand Up @@ -34,9 +33,9 @@ def delete_message(sandbox_id: int, message_id: int) -> EmailMessage:

def list_messages(
sandbox_id: int,
search: Optional[str] = None,
last_id: Optional[int] = None,
page: Optional[int] = None,
search: str | None = None,
last_id: int | None = None,
page: int | None = None,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
) -> list[EmailMessage]:
return messages_api.get_list(
sandbox_id=sandbox_id, search=search, last_id=last_id, page=page
Expand Down
5 changes: 2 additions & 3 deletions examples/sandbox/sandboxes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import Optional

import mailtrap as mt
from mailtrap.models.sandboxes import Sandbox
Expand Down Expand Up @@ -27,8 +26,8 @@ def get_sandbox_by_id(sandbox_id: int) -> Sandbox:

def update_sandbox(
sandbox_id: int,
new_name: Optional[str] = None,
new_email_username: Optional[str] = None,
new_name: str | None = None,
new_email_username: str | None = None,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
) -> Sandbox:
return sandboxes_api.update(
sandbox_id,
Expand Down
3 changes: 1 addition & 2 deletions examples/suppressions/suppressions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import Optional

import mailtrap as mt
from mailtrap.models.suppressions import Suppression
Expand All @@ -11,7 +10,7 @@
suppressions_api = client.suppressions_api.suppressions


def list_suppressions(email: Optional[str] = None) -> list[Suppression]:
def list_suppressions(email: str | None = None) -> list[Suppression]:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return suppressions_api.get_list(email)


Expand Down
7 changes: 3 additions & 4 deletions mailtrap/_deprecation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import functools
import warnings
from collections.abc import Callable
from contextvars import ContextVar
from typing import Callable
from typing import Optional
from typing import ParamSpec
from typing import TypeVar

Expand Down Expand Up @@ -77,8 +76,8 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:


def resolve_renamed_arg(
owner: str, old: str, old_value: Optional[T], new: str, new_value: Optional[T]
) -> Optional[T]:
owner: str, old: str, old_value: T | None, new: str, new_value: T | None
) -> T | None:
"""
Return the value of a renamed constructor argument whose old name stays in the
signature, so code passing the old keyword still type-checks.
Expand Down
5 changes: 2 additions & 3 deletions mailtrap/api/resources/account_accesses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Optional
from urllib.parse import quote

from mailtrap.http import HttpClient
Expand All @@ -12,7 +11,7 @@ def __init__(self, client: HttpClient) -> None:
self._client = client

def get_list(
self, account_id: int, filter_params: Optional[AccountAccessFilterParams] = None
self, account_id: int, filter_params: AccountAccessFilterParams | None = None
) -> list[AccountAccess]:
"""
Get list of account accesses for which specifier_type is User or Invite.
Expand All @@ -36,7 +35,7 @@ def delete(self, account_id: int, account_access_id: int) -> DeletedObject:
self._client.delete(self._api_path(account_id, account_access_id))
return DeletedObject(account_access_id)

def _api_path(self, account_id: int, account_access_id: Optional[int] = None) -> str:
def _api_path(self, account_id: int, account_access_id: int | None = None) -> str:
path = f"/api/accounts/{account_id}/account_accesses"
if account_access_id is not None:
return f"{path}/{quote(str(account_access_id), safe='')}"
Expand Down
6 changes: 2 additions & 4 deletions mailtrap/api/resources/api_tokens.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from mailtrap.http import HttpClient
from mailtrap.models.api_tokens import ApiToken
from mailtrap.models.api_tokens import ApiTokenWithToken
Expand Down Expand Up @@ -54,7 +52,7 @@ def reset(
self,
account_id: int,
api_token_id: int,
token_params: Optional[ResetApiTokenParams] = None,
token_params: ResetApiTokenParams | None = None,
) -> ApiTokenWithToken:
"""
Expire the requested token and create a new token with the same
Expand All @@ -73,7 +71,7 @@ def reset(
return ApiTokenWithToken(**response)

@staticmethod
def _api_path(account_id: int, api_token_id: Optional[int] = None) -> str:
def _api_path(account_id: int, api_token_id: int | None = None) -> str:
path = f"/api/accounts/{account_id}/api_tokens"
if api_token_id is not None:
return f"{path}/{api_token_id}"
Expand Down
4 changes: 1 addition & 3 deletions mailtrap/api/resources/attachments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from mailtrap._deprecation import renamed_kwargs
from mailtrap.http import HttpClient
from mailtrap.models.attachments import Attachment
Expand Down Expand Up @@ -35,7 +33,7 @@ def _api_path(
self,
sandbox_id: int,
message_id: int,
attachment_id: Optional[int] = None,
attachment_id: int | None = None,
) -> str:
path = (
f"/api/accounts/{self._account_id}"
Expand Down
4 changes: 1 addition & 3 deletions mailtrap/api/resources/contact_events.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from mailtrap.http import HttpClient
from mailtrap.models.contacts import ContactEvent
from mailtrap.models.contacts import ContactEventParams
Expand All @@ -22,5 +20,5 @@ def create(
)
return ContactEvent(**response)

def _api_path(self, contact_identifier: Optional[str] = None) -> str:
def _api_path(self, contact_identifier: str | None = None) -> str:
return f"/api/accounts/{self._account_id}/contacts/{contact_identifier}/events"
4 changes: 1 addition & 3 deletions mailtrap/api/resources/contact_exports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from mailtrap.http import HttpClient
from mailtrap.models.contacts import ContactExportDetail
from mailtrap.models.contacts import CreateContactExportParams
Expand All @@ -25,7 +23,7 @@ def get_by_id(self, export_id: int) -> ContactExportDetail:
response = self._client.get(self._api_path(export_id))
return ContactExportDetail(**response)

def _api_path(self, export_id: Optional[int] = None) -> str:
def _api_path(self, export_id: int | None = None) -> str:
path = f"/api/accounts/{self._account_id}/contacts/exports"
if export_id is not None:
return f"{path}/{export_id}"
Expand Down
4 changes: 1 addition & 3 deletions mailtrap/api/resources/contact_fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from mailtrap.http import HttpClient
from mailtrap.models.common import DeletedObject
from mailtrap.models.contacts import ContactField
Expand Down Expand Up @@ -54,7 +52,7 @@ def delete(self, field_id: int) -> DeletedObject:
self._client.delete(self._api_path(field_id))
return DeletedObject(field_id)

def _api_path(self, field_id: Optional[int] = None) -> str:
def _api_path(self, field_id: int | None = None) -> str:
path = f"/api/accounts/{self._account_id}/contacts/fields"
if field_id is not None:
return f"{path}/{field_id}"
Expand Down
4 changes: 1 addition & 3 deletions mailtrap/api/resources/contact_imports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from mailtrap.http import HttpClient
from mailtrap.models.contacts import ContactImport
from mailtrap.models.contacts import ImportContactParams
Expand Down Expand Up @@ -28,7 +26,7 @@ def get_by_id(self, import_id: int) -> ContactImport:
response = self._client.get(self._api_path(import_id))
return ContactImport(**response)

def _api_path(self, import_id: Optional[int] = None) -> str:
def _api_path(self, import_id: int | None = None) -> str:
path = f"/api/accounts/{self._account_id}/contacts/imports"
if import_id is not None:
return f"{path}/{import_id}"
Expand Down
Loading
Loading