From de4ec94d0f88ca3d1a58b303340df9f2c3986a7a Mon Sep 17 00:00:00 2001 From: Michiel <918128+mvanderlee@users.noreply.github.com> Date: Sun, 10 Mar 2024 02:01:06 +0100 Subject: [PATCH] Add support back for Python3.8 --- .github/workflows/python-package.yml | 4 ++-- .gitignore | 3 +++ .pre-commit-config.yaml | 1 + marshmallow_dataclass/__init__.py | 7 ++++++- marshmallow_dataclass/typing.py | 7 ++++++- setup.py | 5 +++-- tests/test_mypy.yml | 2 +- 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index c5fd3c2d..f49a26b7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -12,10 +12,10 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest"] - python_version: ["3.9", "3.10", "3.11", "3.12", "pypy3.10"] + python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"] include: - os: "ubuntu-20.04" - python_version: "3.9" + python_version: "3.8" runs-on: ${{ matrix.os }} steps: diff --git a/.gitignore b/.gitignore index cbfc4da4..02da4179 100644 --- a/.gitignore +++ b/.gitignore @@ -95,6 +95,9 @@ venv.bak/ # Rope project settings .ropeproject +# VSCode project settings +.vscode + # mkdocs documentation /site diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d465df2a..dade9fa2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,7 @@ repos: rev: v3.3.1 hooks: - id: pyupgrade + # I've kept it on py3.7 so that it doesn't replace `Dict` with `dict` args: ["--py37-plus"] - repo: https://github.com/python/black rev: 23.1.0 diff --git a/marshmallow_dataclass/__init__.py b/marshmallow_dataclass/__init__.py index 61c4e085..8fd52ec0 100644 --- a/marshmallow_dataclass/__init__.py +++ b/marshmallow_dataclass/__init__.py @@ -43,7 +43,7 @@ class User: import warnings from enum import Enum from functools import lru_cache, partial -from typing import Annotated, Any, Callable, Dict, FrozenSet, List, Mapping +from typing import Any, Callable, Dict, FrozenSet, List, Mapping from typing import NewType as typing_NewType from typing import ( Optional, @@ -65,6 +65,11 @@ class User: from marshmallow_dataclass.lazy_class_attribute import lazy_class_attribute +if sys.version_info >= (3, 9): + from typing import Annotated +else: + from typing_extensions import Annotated + if sys.version_info >= (3, 11): from typing import dataclass_transform else: diff --git a/marshmallow_dataclass/typing.py b/marshmallow_dataclass/typing.py index 35bdee23..4db2f152 100644 --- a/marshmallow_dataclass/typing.py +++ b/marshmallow_dataclass/typing.py @@ -1,7 +1,12 @@ -from typing import Annotated +import sys import marshmallow.fields +if sys.version_info >= (3, 9): + from typing import Annotated +else: + from typing_extensions import Annotated + Url = Annotated[str, marshmallow.fields.Url] Email = Annotated[str, marshmallow.fields.Email] diff --git a/setup.py b/setup.py index 003fe1f7..d446bf87 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup VERSION = "8.6.0" @@ -8,6 +8,7 @@ "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", "Programming Language :: Python", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -47,7 +48,7 @@ keywords=["marshmallow", "dataclass", "serialization"], classifiers=CLASSIFIERS, license="MIT", - python_requires=">=3.9", + python_requires=">=3.8", install_requires=[ "marshmallow>=3.18.0,<4.0", "typing-inspect>=0.8.0,<1.0", diff --git a/tests/test_mypy.yml b/tests/test_mypy.yml index 47673193..1487cb73 100644 --- a/tests/test_mypy.yml +++ b/tests/test_mypy.yml @@ -6,7 +6,7 @@ follow_imports = silent plugins = marshmallow_dataclass.mypy show_error_codes = true - python_version = 3.9 + python_version = 3.8 env: - PYTHONPATH=. main: |