From 2bc4fb9bf9d6355fac20a79c671c6c3a2b34b7f7 Mon Sep 17 00:00:00 2001 From: Adrien Barbaresi Date: Thu, 24 Aug 2023 14:18:28 +0200 Subject: [PATCH] use fromisoformat backport for Python versions < 3.11 --- htmldate/__init__.py | 8 +++++--- setup.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htmldate/__init__.py b/htmldate/__init__.py index 2c26dd56..8a1b44cc 100644 --- a/htmldate/__init__.py +++ b/htmldate/__init__.py @@ -11,15 +11,17 @@ import logging + from datetime import datetime +from sys import version_info + -try: - datetime.fromisoformat # type: ignore[attr-defined] -except AttributeError: # Python 3.6 +if version_info.minor < 11: from backports.datetime_fromisoformat import MonkeyPatch # type: ignore MonkeyPatch.patch_fromisoformat() + from .core import find_date logging.getLogger(__name__).addHandler(logging.NullHandler()) diff --git a/setup.py b/setup.py index 32d95485..b7044d86 100644 --- a/setup.py +++ b/setup.py @@ -113,7 +113,7 @@ def get_version(package): include_package_data=True, python_requires=">=3.6", install_requires=[ - "backports-datetime-fromisoformat; python_version < '3.7'", + "backports-datetime-fromisoformat; python_version < '3.11'", "charset_normalizer >= 3.0.1; python_version < '3.7'", "charset_normalizer >= 3.2.0; python_version >= '3.7'", "dateparser >= 1.1.2", # 1.1.3+ slower