Skip to content

Commit

Permalink
Drop Python 3.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jayqi committed Feb 11, 2024
1 parent 22c1976 commit 51a5e86
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# erdantic Changelog

## v0.8.0 (Unreleased)

- Removed support for Python 3.7.

## v0.7.0 (2024-02-11)

This will be the last version that supports Python 3.7.
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 13 additions & 2 deletions erdantic/base.py
Original file line number Diff line number Diff line change
@@ -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 = """<tr><td>{name}</td><td port="{name}">{type_name}</td></tr>"""

Expand Down
28 changes: 10 additions & 18 deletions erdantic/typing.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 1 addition & 7 deletions erdantic/version.py
Original file line number Diff line number Diff line change
@@ -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])
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" }]
Expand All @@ -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",
Expand All @@ -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]
Expand Down
11 changes: 1 addition & 10 deletions tests/test_typing.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 51a5e86

Please sign in to comment.