diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03ae906..7f44972 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] steps: - name: Checkout diff --git a/setup.cfg b/setup.cfg index a2cfb81..674d956 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,11 +15,11 @@ classifiers = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Topic :: Software Development :: Libraries Topic :: Software Development :: Libraries :: Python Modules Topic :: Utilities @@ -28,7 +28,7 @@ classifiers = package_dir = = src packages = find: -python_requires = >=3.7 +python_requires = >=3.8 include_package_data = True install_requires = typing-extensions>=3.10,!=4.6.0 @@ -47,7 +47,7 @@ dev = flake8-bugbear flake8-isort furo - importlib_metadata<5; python_version=="3.7" + importlib_metadata invoke isort mypy diff --git a/src/pydash/types.py b/src/pydash/types.py index 6b14763..8c1535e 100644 --- a/src/pydash/types.py +++ b/src/pydash/types.py @@ -1,15 +1,11 @@ +from decimal import Decimal import typing as t from typing_extensions import Protocol -if t.TYPE_CHECKING: - # F401: imported but unused - # py3.7 flake8 doesn't get it for type aliases - from decimal import Decimal # noqa: F401 - IterateeObjT = t.Union[int, str, t.List, t.Tuple, t.Dict] -NumberT = t.Union[float, int, "Decimal"] +NumberT = t.Union[float, int, Decimal] NumberNoDecimalT = t.Union[float, int] PathT = t.Union[t.Hashable, t.List[t.Hashable]] diff --git a/src/pydash/utilities.py b/src/pydash/utilities.py index 89c1a25..8b843a6 100644 --- a/src/pydash/utilities.py +++ b/src/pydash/utilities.py @@ -5,7 +5,7 @@ """ from collections import namedtuple -from datetime import datetime +from datetime import datetime, timezone from functools import partial, wraps import math from random import randint, uniform @@ -739,16 +739,9 @@ def now() -> int: .. versionchanged:: 3.0.0 Use ``datetime`` module for calculating elapsed time. """ - epoch = datetime.utcfromtimestamp(0) - delta = datetime.utcnow() - epoch - - if hasattr(delta, "total_seconds"): - seconds = delta.total_seconds() - else: # pragma: no cover - # PY26 - seconds = (delta.microseconds + (delta.seconds + delta.days * 24 * 3600) * 10**6) / 10**6 - - return int(seconds * 1000) + epoch = datetime.fromtimestamp(0, timezone.utc) + delta = datetime.now(timezone.utc) - epoch + return int(delta.total_seconds() * 1000) def over(funcs: t.Iterable[t.Callable[P, T]]) -> t.Callable[P, t.List[T]]: diff --git a/tests/test_strings.py b/tests/test_strings.py index e15d0dc..26b9fe6 100644 --- a/tests/test_strings.py +++ b/tests/test_strings.py @@ -1,5 +1,4 @@ import re -import sys from urllib.parse import parse_qsl, urlsplit import pytest @@ -228,37 +227,13 @@ def test_escape(case, expected): ("abc", "abc"), ("", ""), (None, ""), - ], -) -def test_escape_reg_exp(case, expected): - assert _.escape_reg_exp(case) == expected - - -@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher") -@parametrize( - "case,expected", - [ # noqa ( "[pydash](http://pydash.readthedocs.org/)", "\\[pydash\\]\\(http://pydash\\.readthedocs\\.org/\\)", ), ], ) -def test_escape_reg_exp_gte_py37(case, expected): - assert _.escape_reg_exp(case) == expected - - -@pytest.mark.skipif(sys.version_info >= (3, 7), reason="requires python3.6 or lower") -@parametrize( - "case,expected", - [ # noqa - ( - "[pydash](http://pydash.readthedocs.org/)", # noqa - r"\[pydash\]\(http\:\/\/pydash\.readthedocs\.org\/\)", - ), - ], -) -def test_escape_reg_exp_lte_py36(case, expected): +def test_escape_reg_exp(case, expected): assert _.escape_reg_exp(case) == expected diff --git a/tox.ini b/tox.ini index c7ee4f7..f783a51 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,14 @@ [tox] -envlist = py37, py38, py39, py310, py311 +envlist = py38, py39, py310, py311, py312 isolated_build = true [gh-actions] python = - 3.7: py37 3.8: py38 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] passenv = *