Skip to content

Commit 934541a

Browse files
committed
Use "PEP 604 – Allow writing union types as X | Y"
First added in Python 3.10, now that 3.9 is EOL'd.
1 parent 52b24c6 commit 934541a

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

.github/workflows/test_and_build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
11+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1212

1313
steps:
1414
- uses: actions/checkout@v3

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
In Development
22
--------------
33

4-
* Python 3.8 is no longer supported.
4+
* Python 3.8 and 3.9 are no longer supported.
55

66
2.3.0 (August 26, 2025)
77
-----------------------

email_validator/syntax.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import unicodedata
99
import idna # implements IDNA 2008; Python's codec is only IDNA 2003
1010
import ipaddress
11-
from typing import Optional, TypedDict, Union
11+
from typing import Optional, TypedDict
1212

1313

1414
def split_email(email: str) -> tuple[Optional[str], str, str, bool]:
@@ -758,7 +758,7 @@ def validate_email_length(addrinfo: ValidatedEmail) -> None:
758758

759759

760760
class DomainLiteralValidationResult(TypedDict):
761-
domain_address: Union[ipaddress.IPv4Address, ipaddress.IPv6Address]
761+
domain_address: ipaddress.IPv4Address | ipaddress.IPv6Address
762762
domain: str
763763

764764

@@ -767,7 +767,7 @@ def validate_email_domain_literal(domain_literal: str) -> DomainLiteralValidatio
767767
# a compressed/normalized address.
768768
# RFC 5321 4.1.3 and RFC 5322 3.4.1.
769769

770-
addr: Union[ipaddress.IPv4Address, ipaddress.IPv6Address]
770+
addr: ipaddress.IPv4Address | ipaddress.IPv6Address
771771

772772
# Try to parse the domain literal as an IPv4 address.
773773
# There is no tag for IPv4 addresses, so we can never

email_validator/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import warnings
2-
from typing import Any, Optional, Union
2+
from typing import Any, Optional
33

44

55
class ValidatedEmail:
@@ -68,7 +68,7 @@ def email(self) -> str:
6868

6969
"""For backwards compatibility, some fields are also exposed through a dict-like interface. Note
7070
that some of the names changed when they became attributes."""
71-
def __getitem__(self, key: str) -> Union[Optional[str], bool, list[tuple[int, str]]]:
71+
def __getitem__(self, key: str) -> Optional[str] | bool | list[tuple[int, str]]:
7272
warnings.warn("dict-like access to the return value of validate_email is deprecated and may not be supported in the future.", DeprecationWarning, stacklevel=2)
7373
if key == "email":
7474
return self.normalized

email_validator/validate_email.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Union, TYPE_CHECKING
1+
from typing import Optional, TYPE_CHECKING
22
import unicodedata
33

44
from .exceptions import EmailSyntaxError
@@ -14,7 +14,7 @@
1414

1515

1616
def validate_email(
17-
email: Union[str, bytes],
17+
email: str | bytes,
1818
/, # prior arguments are positional-only
1919
*, # subsequent arguments are keyword-only
2020
allow_smtputf8: Optional[bool] = None,

0 commit comments

Comments
 (0)