diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d92dd3d2..240df20e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,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" ] services: mongodb: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8f93c624..1fa23d2d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: hooks: - id: pyupgrade args: - - --py37-plus + - --py38-plus - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.0.280 hooks: diff --git a/pyproject.toml b/pyproject.toml index 705f032c..b06857ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "starlette-admin" description = "Fast, beautiful and extensible administrative interface framework for Starlette/FastApi applications" readme = "README.md" license = "MIT" -requires-python = ">=3.7" +requires-python = ">=3.8" keywords = ["sqlalchemy", "sqlmodel", "mongoengine", "odmantic", "starlette", "fastapi", "admin", "dashboard", "datatables"] authors = [ { name = "Jocelin Hounon", email = "hounonj@gmail.com" }, @@ -49,7 +49,7 @@ test = [ "pytest-asyncio >=0.20.2, <0.22.0", "mypy ==1.4.1", "ruff ==0.0.280", - "black ==23.3.0", + "black ==23.7.0", "httpx >=0.23.3, <0.25.0", "coverage >=7.0.0, <7.3.0", "SQLAlchemy-Utils >=0.40.0, <0.42.0", @@ -58,7 +58,7 @@ test = [ "phonenumbers >=8.13.3, <8.14.0", "passlib >=1.7.4, <1.8.0", "backports.zoneinfo; python_version<'3.9'", - "sqlalchemy-file >=0.4.0, <0.5.0", + "sqlalchemy-file >=0.5.0, <0.6.0", "fasteners ==0.18", "PyMySQL[rsa] >=1.0.2, <1.2.0", "psycopg2-binary >=2.9.5, <3.0.0", @@ -189,7 +189,7 @@ ignore = [ "E501", # line too long, handled by black "N818", # Exception {name} should be named with an Error suffix ] -target-version = "py37" +target-version = "py38" [tool.ruff.isort] known-third-party = ["starlette_admin"] @@ -215,7 +215,6 @@ ignore_missing_imports = true module = [ "starlette_admin.contrib.sqla.helpers", "starlette_admin.contrib.sqla.view", - "starlette_admin.converters" ] warn_unused_ignores = false diff --git a/starlette_admin/contrib/sqla/fields.py b/starlette_admin/contrib/sqla/fields.py index 027f0b72..e8f6fba6 100644 --- a/starlette_admin/contrib/sqla/fields.py +++ b/starlette_admin/contrib/sqla/fields.py @@ -49,7 +49,7 @@ async def serialize_value( def _serialize_sqlalchemy_file_library( request: Request, value: Any, action: RequestAction, is_multiple: bool ) -> Optional[Union[List[Dict[str, Any]], Dict[str, Any]]]: - from sqlalchemy_file import File + from sqlalchemy_file import File # type: ignore[attr-defined] if isinstance(value, File) or ( isinstance(value, list) and all(isinstance(f, File) for f in value) diff --git a/starlette_admin/converters.py b/starlette_admin/converters.py index 42a578bb..b4bd04d4 100644 --- a/starlette_admin/converters.py +++ b/starlette_admin/converters.py @@ -2,7 +2,6 @@ import decimal import enum import inspect -import sys import typing from abc import abstractmethod from typing import ( @@ -12,6 +11,8 @@ Optional, Sequence, Type, + get_args, + get_origin, ) from starlette_admin.exceptions import NotSupportedAnnotation @@ -30,14 +31,6 @@ TimeField, ) -if sys.version_info >= (3, 8): # pragma: no cover - from typing import get_args, get_origin -else: # pragma: no cover - try: - from typing_extensions import get_args, get_origin - except ImportError: - get_args, get_origin = None, None # type: ignore[assignment] - def converts( *args: Any,