From 3c057f4252bc66937a4d15f4e37d396ea1d4c3ac Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 2 Jul 2023 09:47:06 -0400 Subject: [PATCH 1/6] Drop support for Python 3.7 which is EOL'd now --- .github/workflows/test_and_build.yaml | 2 +- .travis.yml | 1 - CHANGELOG.md | 5 +++++ README.md | 2 +- setup.cfg | 3 +-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_and_build.yaml b/.github/workflows/test_and_build.yaml index e80acd6..8c111cc 100644 --- a/.github/workflows/test_and_build.yaml +++ b/.github/workflows/test_and_build.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12.0-alpha.5"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.0-alpha.5"] steps: - uses: actions/checkout@v3 diff --git a/.travis.yml b/.travis.yml index 3a283dc..40efcf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ language: python cache: pip python: -- '3.7' - '3.8' - '3.9' - '3.10' diff --git a/CHANGELOG.md b/CHANGELOG.md index 48a31c6..d1e40d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +In Development +-------------- + +* Python 3.8 is now required. + 2.0.0 (April 15, 2023) ---------------------- diff --git a/README.md b/README.md index 60077ca..9f142f1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ email-validator: Validate Email Addresses ========================================= A robust email address syntax and deliverability validation library for -Python 3.7+ by [Joshua Tauberer](https://joshdata.me). +Python by [Joshua Tauberer](https://joshdata.me). This library validates that a string is of the form `name@example.com` and optionally checks that the domain name is set up to receive email. diff --git a/setup.cfg b/setup.cfg index d299498..85d227f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,7 +14,6 @@ classifiers = Intended Audience :: Developers License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -27,7 +26,7 @@ packages = find: install_requires = dnspython>=2.0.0 # optional if deliverability check isn't needed idna>=2.0.0 -python_requires = >=3.7 +python_requires = >=3.8 [options.package_data] * = py.typed From b88cd1c5300a428a2f986dfdc25754f75ba5208d Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 2 Jul 2023 09:47:25 -0400 Subject: [PATCH 2/6] Remove .travis.yml since we now do CI with GitHub actions --- .travis.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 40efcf2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -os: linux -dist: bionic -language: python -cache: pip - -python: -- '3.8' -- '3.9' -- '3.10' -- '3.11' -- '3.12-dev' - -install: -- make install - -script: -- make typing -- make lint -- make test - -after_success: -- bash <(curl -s https://codecov.io/bash) From f95ddfe8596138a5053b32458b89be743f9ebe6f Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 2 Jul 2023 09:49:34 -0400 Subject: [PATCH 3/6] Update test_requirements.txt for Python 3.8 --- test_requirements.txt | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/test_requirements.txt b/test_requirements.txt index 5f11247..459c5d0 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,5 +1,5 @@ # This file was generated by running: -# sudo docker run --rm -it --network=host python:3.7-slim /bin/bash +# sudo docker run --rm -it --network=host python:3.8-slim /bin/bash # pip install dnspython idna # from setup.cfg # pip install pytest pytest-cov coverage flake8 mypy # pip freeze @@ -7,24 +7,20 @@ # the earliest Python version we support, and some exception # messages may depend on package versions, so we pin versions # for reproducible testing.) -attrs==22.2.0 -coverage==7.2.1 +coverage==7.2.7 dnspython==2.3.0 -exceptiongroup==1.1.0 -flake8==5.0.4 +exceptiongroup==1.1.1 +flake8==6.0.0 idna==3.4 -importlib-metadata==4.2.0 iniconfig==2.0.0 mccabe==0.7.0 -mypy==1.0.1 +mypy==1.4.1 mypy-extensions==1.0.0 -packaging==23.0 -pluggy==1.0.0 -pycodestyle==2.9.1 -pyflakes==2.5.0 -pytest==7.2.1 -pytest-cov==4.0.0 +packaging==23.1 +pluggy==1.2.0 +pycodestyle==2.10.0 +pyflakes==3.0.1 +pytest==7.4.0 +pytest-cov==4.1.0 tomli==2.0.1 -typed-ast==1.5.4 -typing_extensions==4.5.0 -zipp==3.15.0 +typing_extensions==4.7.0 From 7fe4997eb6317520f72204add13a8502fef47b29 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 2 Jul 2023 09:47:53 -0400 Subject: [PATCH 4/6] Mark the email address argument to validate_email as positional-only --- CHANGELOG.md | 1 + email_validator/validate_email.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1e40d4..fe1025d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ In Development -------------- * Python 3.8 is now required. +* The email address argument to validate_email is now marked as positional-only to better reflect the documented usage using the new Python 3.8 feature. 2.0.0 (April 15, 2023) ---------------------- diff --git a/email_validator/validate_email.py b/email_validator/validate_email.py index 0d8f581..b33394a 100644 --- a/email_validator/validate_email.py +++ b/email_validator/validate_email.py @@ -7,8 +7,8 @@ def validate_email( email: Union[str, bytes], - # /, # not supported in Python 3.6, 3.7 - *, + /, # prior arguments are positional-only + *, # subsequent arguments are keyword-only allow_smtputf8: Optional[bool] = None, allow_empty_local: bool = False, allow_quoted_local: Optional[bool] = None, From b6bc3fec6b2e78e9bf92581a14d57ddbe53d2dde Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 2 Jul 2023 09:55:49 -0400 Subject: [PATCH 5/6] Drop Python 3.12 pre-release testing because it's giving strange errors --- .github/workflows/test_and_build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_build.yaml b/.github/workflows/test_and_build.yaml index 8c111cc..6a1d890 100644 --- a/.github/workflows/test_and_build.yaml +++ b/.github/workflows/test_and_build.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.0-alpha.5"] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 From d5252c0175410253a243abca07de27704eb6e575 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 2 Jul 2023 10:26:25 -0400 Subject: [PATCH 6/6] Use the new Python 3.8 walrus operator and simplify some if statements --- email_validator/syntax.py | 9 +++------ email_validator/validate_email.py | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/email_validator/syntax.py b/email_validator/syntax.py index abb4ea9..7287476 100644 --- a/email_validator/syntax.py +++ b/email_validator/syntax.py @@ -69,8 +69,7 @@ def validate_email_local_part(local: str, allow_smtputf8: bool = True, allow_emp # so if it was originally quoted (quoted_local_part is True) and this regex matches, # it's ok. # (RFC 5321 4.1.2 / RFC 5322 3.2.4). - m = DOT_ATOM_TEXT.match(local) - if m: + if DOT_ATOM_TEXT.match(local): # It's valid. And since it's just the permitted ASCII characters, # it's normalized and safe. If the local part was originally quoted, # the quoting was unnecessary and it'll be returned as normalized to @@ -89,8 +88,7 @@ def validate_email_local_part(local: str, allow_smtputf8: bool = True, allow_emp # RFC 6531 section 3.3. valid: Optional[str] = None requires_smtputf8 = False - m = DOT_ATOM_TEXT_INTL.match(local) - if m: + if DOT_ATOM_TEXT_INTL.match(local): # But international characters in the local part may not be permitted. if not allow_smtputf8: # Check for invalid characters against the non-internationalized @@ -347,8 +345,7 @@ def validate_email_domain_name(domain, test_environment=False, globally_delivera # Check the syntax of the string returned by idna.encode. # It should never fail. - m = DOT_ATOM_TEXT_HOSTNAME.match(ascii_domain) - if not m: + if not DOT_ATOM_TEXT_HOSTNAME.match(ascii_domain): raise EmailSyntaxError("The email address contains invalid characters after the @-sign after IDNA encoding.") # Check the length of the domain name in bytes. diff --git a/email_validator/validate_email.py b/email_validator/validate_email.py index b33394a..0d2e7a8 100644 --- a/email_validator/validate_email.py +++ b/email_validator/validate_email.py @@ -58,8 +58,7 @@ def validate_email( # part if the local part is quoted. If the address is quoted, # split it at a non-escaped @-sign and unescape the escaping. quoted_local_part = False - m = QUOTED_LOCAL_PART_ADDR.match(email) - if m: + if m := QUOTED_LOCAL_PART_ADDR.match(email): quoted_local_part = True local_part, domain_part = m.groups()