From 4484dc63dc9eda5aa96a1097a47d80e7a495ae1c Mon Sep 17 00:00:00 2001 From: Jay Qi <2721979+jayqi@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:43:38 -0500 Subject: [PATCH] Drop Python 3.7 support (#102) * Drop Python 3.7 support * Add PR number --------- Co-authored-by: Jay Qi --- .github/workflows/tests.yml | 2 +- HISTORY.md | 4 ++++ Makefile | 3 ++- erdantic/base.py | 15 +++++++++++++-- erdantic/typing.py | 28 ++++++++++------------------ erdantic/version.py | 8 +------- pyproject.toml | 5 +---- tests/test_typing.py | 11 +---------- 8 files changed, 33 insertions(+), 43 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5aa82d2e..33b66371 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] # [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/HISTORY.md b/HISTORY.md index 7dc06e49..688b93ba 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # erdantic Changelog +## v0.8.0 (Unreleased) + +- Removed support for Python 3.7. ([PR #102](https://github.com/drivendataorg/erdantic/pull/102)) + ## v0.7.0 (2024-02-11) This will be the last version that supports Python 3.7. diff --git a/Makefile b/Makefile index 6a1bb1d5..a2aefcfb 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,8 @@ docs-notebooks: rm -f docs/docs/examples/diagram.png format: ## format code with black - black erdantic tests docs + ruff format erdantic tests docs + ruff check --fix erdantic tests docs help: @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) diff --git a/erdantic/base.py b/erdantic/base.py index a3bc12a0..9bd56638 100644 --- a/erdantic/base.py +++ b/erdantic/base.py @@ -1,9 +1,20 @@ from abc import ABC, abstractmethod import inspect -from typing import Any, Callable, Dict, Generic, List, Optional, Type, TypeVar, Union +from typing import ( + Any, + Callable, + Dict, + Final, + Generic, + List, + Optional, + Type, + TypeVar, + Union, +) from erdantic.exceptions import InvalidModelAdapterError, ModelAdapterNotFoundError -from erdantic.typing import Final, GenericAlias, repr_type +from erdantic.typing import GenericAlias, repr_type _row_template = """{name}{type_name}""" diff --git a/erdantic/typing.py b/erdantic/typing.py index 76f8535b..ca4fb261 100644 --- a/erdantic/typing.py +++ b/erdantic/typing.py @@ -1,30 +1,22 @@ import collections.abc from enum import Enum -from typing import Any, List, Type, Union +from typing import ( + Any, + ForwardRef, + List, + Literal, + Type, + Union, + get_args, + get_origin, +) # Note Python 3.9's types.GenericAlias != typing._GenericAlias # We still want typing._GenericAlias for typing module's deprecated capital generic aliases from typing import _GenericAlias as GenericAlias # type: ignore # Python 3.7+ -try: - from typing import Final # type: ignore # Python 3.8+ -except ImportError: - from typing_extensions import Final # type: ignore # noqa: F401 # Python 3.7 - -from typing import ForwardRef # docs claim Python >= 3.7.4 but actually it's in Python 3.7.0+ - -try: - from typing import Literal # type: ignore # Python >= 3.8 -except ImportError: - from typing_extensions import Literal # type: ignore # Python == 3.7.* - from erdantic.exceptions import _StringForwardRefError, _UnevaluatedForwardRefError -try: - from typing import get_args, get_origin # type: ignore # Python 3.8+ -except ImportError: - from typing_extensions import get_args, get_origin # type: ignore # Python 3.7 - def is_many(tp: Union[type, GenericAlias]) -> bool: """Given a type annotation, returns True if it represents a collection of many elements. diff --git a/erdantic/version.py b/erdantic/version.py index 5519be35..e5390f4a 100644 --- a/erdantic/version.py +++ b/erdantic/version.py @@ -1,9 +1,3 @@ -import sys - -if sys.version_info[:2] >= (3, 8): - import importlib.metadata as importlib_metadata -else: - import importlib_metadata - +import importlib_metadata __version__ = importlib_metadata.version(__name__.split(".", 1)[0]) diff --git a/pyproject.toml b/pyproject.toml index 6ffe5960..8f8feb75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "erdantic" -version = "0.7.0" +version = "0.8.0.dev" description = "Entity relationship diagrams for Python data model classes like Pydantic." readme = "README.md" authors = [{ name = "DrivenData", email = "info@drivendata.org" }] @@ -16,7 +16,6 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -25,12 +24,10 @@ classifiers = [ ] requires-python = ">=3.7" dependencies = [ - "importlib_metadata ; python_version < '3.8'", "pydantic >= 2", "pydantic-core", "pygraphviz", "typer", - "typing_extensions > 4 ; python_version < '3.8'", ] [project.scripts] diff --git a/tests/test_typing.py b/tests/test_typing.py index 2ecaeb9c..463ce088 100644 --- a/tests/test_typing.py +++ b/tests/test_typing.py @@ -1,16 +1,7 @@ from enum import Enum, IntFlag import sys import typing -from typing import ForwardRef # docs claim Python >= 3.7.4 but actually it's in Python 3.7.0+ - -try: - from typing import Literal # type: ignore # Python >=3.8 -except ImportError: - try: - from typing_extensions import Literal # type: ignore # Python ==3.7.* - except ImportError: - Literal = None # type: ignore # Python <3.7 - +from typing import ForwardRef, Literal import pytest