Skip to content

Commit

Permalink
chore: Drop support for Python 3.7 (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonagestam authored Mar 26, 2023
1 parent 7acaf97 commit 68ee857
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12-dev"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=67.4.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
target-version = ["py37"]
target-version = ["py38"]

[tool.pytest.ini_options]
testpaths = ["tests", "src", "docs"]
Expand All @@ -15,7 +15,7 @@ markers = [

[tool.ruff]
fix = true
target-version = "py37"
target-version = "py38"
extend-select = [
# bugbear
"B",
Expand Down
8 changes: 3 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Expand All @@ -30,12 +29,11 @@ include_package_data = True
package_dir =
=src
packages = find:
python_requires = >=3.7
python_requires = >=3.8
install_requires =
typeguard>=2.10,<3
typing_extensions>=4.3.0
numerary>=0.3.0,<0.4; python_version<'3.8'
numerary>=0.4.3; python_version>='3.8'
numerary>=0.4.3

[options.packages.find]
where = src
Expand Down Expand Up @@ -64,7 +62,7 @@ test =
coverage

[mypy]
python_version = 3.7
python_version = 3.8
show_error_codes = True
pretty = True
files = src, tests
Expand Down
5 changes: 2 additions & 3 deletions src/phantom/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
from typing import Generic
from typing import Iterable
from typing import Iterator
from typing import Protocol
from typing import TypeVar

from typing_extensions import Protocol
from typing_extensions import runtime_checkable
from typing import runtime_checkable

from . import _hypothesis
from ._utils.misc import BoundType
Expand Down
17 changes: 0 additions & 17 deletions src/phantom/_utils/compat.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/phantom/_utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import types
from dataclasses import is_dataclass
from itertools import product
from typing import Final
from typing import MutableMapping
from typing import MutableSequence
from typing import MutableSet
from typing import NewType
from typing import Tuple
from typing import Union

from typing_extensions import Final
from typing_extensions import TypeGuard
from typing_extensions import get_args
from typing_extensions import get_origin
Expand Down
7 changes: 3 additions & 4 deletions src/phantom/_utils/types.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Protocol
from typing import TypeVar
from typing import runtime_checkable

from typing_extensions import Protocol
from typing_extensions import runtime_checkable

from .compat import CachingProtocolMeta
from numerary.protocol import CachingProtocolMeta

T_contra = TypeVar("T_contra", contravariant=True)
U_co = TypeVar("U_co", covariant=True)
Expand Down
2 changes: 1 addition & 1 deletion src/phantom/bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from typing import Any
from typing import Callable
from typing import Final
from typing import Iterable
from typing import Sequence
from typing import TypeVar
from typing import cast

from typing_extensions import Final
from typing_extensions import TypeAlias
from typing_extensions import get_args

Expand Down
2 changes: 1 addition & 1 deletion src/phantom/ext/phonenumbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"""
from __future__ import annotations

from typing import Final
from typing import cast

import phonenumbers
from typing_extensions import Final

from phantom import Phantom
from phantom.bounds import parse_str
Expand Down
5 changes: 2 additions & 3 deletions src/phantom/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ def take_portion(portion: Portion, whole: Natural) -> float:

from contextlib import suppress
from typing import Any
from typing import Final
from typing import Protocol
from typing import TypeVar

from typing_extensions import Final
from typing_extensions import Protocol

from . import Phantom
from . import Predicate
from . import _hypothesis
Expand Down
4 changes: 2 additions & 2 deletions src/phantom/iso3166.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"""
from __future__ import annotations

from typing import Final
from typing import Literal
from typing import Union
from typing import cast

from typing_extensions import Final
from typing_extensions import Literal
from typing_extensions import get_args

from phantom import Phantom
Expand Down
3 changes: 1 addition & 2 deletions src/phantom/predicates/boolean.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Iterable
from typing import Literal
from typing import TypeVar

from typing_extensions import Literal

from . import Predicate
from ._utils import bind_name

Expand Down
2 changes: 1 addition & 1 deletion src/phantom/schema.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Literal
from typing import Optional
from typing import Sequence

from typing_extensions import Literal
from typing_extensions import TypedDict
from typing_extensions import final

Expand Down
18 changes: 6 additions & 12 deletions src/phantom/sized.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ class SizedStr(str, PhantomBound[str], max=255):
"""
from __future__ import annotations

# This is the closest I could find to documentation of _ProtocolMeta.
# https://github.com/python/cpython/commit/74d7f76e2c953fbfdb7ce01b7319d91d471cc5ef
from typing import Any
from typing import Generic
from typing import Iterable
from typing import Protocol
from typing import Sized
from typing import TypeVar
from typing import _ProtocolMeta
from typing import runtime_checkable

from typing_extensions import Protocol
from typing_extensions import get_args
from typing_extensions import runtime_checkable

from . import Phantom
from . import PhantomMeta
Expand All @@ -47,15 +50,6 @@ class SizedStr(str, PhantomBound[str], max=255):
from .predicates import numeric
from .schema import Schema

# We attempt to import _ProtocolMeta from typing_extensions to support Python 3.7 but
# fall back the typing module to support Python 3.8+. This is the closest I could find
# to documentation of _ProtocolMeta.
# https://github.com/python/cpython/commit/74d7f76e2c953fbfdb7ce01b7319d91d471cc5ef
try:
from typing_extensions import _ProtocolMeta # type: ignore[attr-defined]
except ImportError:
from typing import _ProtocolMeta

__all__ = (
"SizedIterable",
"PhantomSized",
Expand All @@ -74,7 +68,7 @@ class SizedIterable(Sized, Iterable[T], Protocol[T]):
"""Intersection of :py:class:`typing.Sized` and :py:class:`typing.Iterable`."""


class SizedIterablePhantomMeta(PhantomMeta, _ProtocolMeta): # type: ignore[misc]
class SizedIterablePhantomMeta(PhantomMeta, _ProtocolMeta):
...


Expand Down
2 changes: 1 addition & 1 deletion tests/test_sized.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dataclasses import dataclass
from typing import Final
from typing import Generic
from typing import TypeVar

import pytest
from typing_extensions import Final
from typing_extensions import get_args
from typing_extensions import get_origin

Expand Down

0 comments on commit 68ee857

Please sign in to comment.