Skip to content

Commit ed997c9

Browse files
committed
chore: drop testing for EOL Python 3.7
1 parent 014c6ff commit ed997c9

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed

.github/workflows/tests.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
20+
python-version: ["3.8", "3.9", "3.10", "3.11"]
2121
os: [ubuntu-latest, macos-latest, windows-latest]
2222
steps:
2323
- uses: actions/checkout@v3

docker-compose.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '3.5'
2+
3+
services:
4+
5+
graphene_federation:
6+
container_name: pydantic
7+
build:
8+
context: .
9+
environment:
10+
- TERM=xterm-256color
11+
volumes:
12+
- ./:/workdir

graphene_pydantic/converters.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
UUID,
2525
Union,
2626
)
27+
from graphene.types.base import BaseType
2728
from graphene.types.datetime import Date, DateTime, Time
2829
from pydantic import BaseModel
2930
from pydantic.fields import FieldInfo
3031
from pydantic_core import PydanticUndefined
3132

32-
from .registry import Registry
33+
from .registry import Placeholder, Registry
3334
from .util import construct_union_class_name, evaluate_forward_ref
3435

3536
PYTHON10 = sys.version_info >= (3, 10)
@@ -175,7 +176,7 @@ def convert_pydantic_type(
175176
registry: Registry,
176177
parent_type: T.Type = None,
177178
model: T.Type[BaseModel] = None,
178-
) -> Type: # noqa: C901
179+
) -> T.Union[Type[T.Union[BaseType, List]], Placeholder]: # noqa: C901
179180
"""
180181
Convert a Pydantic type to a Graphene Field type, including not just the
181182
native Python type but any additional metadata (e.g. shape) that Pydantic
@@ -197,7 +198,7 @@ def find_graphene_type(
197198
registry: Registry,
198199
parent_type: T.Type = None,
199200
model: T.Type[BaseModel] = None,
200-
) -> Type: # noqa: C901
201+
) -> T.Union[Type[T.Union[BaseType, List]], Placeholder]: # noqa: C901
201202
"""
202203
Map a native Python type to a Graphene-supported Field type, where possible,
203204
throwing an error if we don't know what to map it to.
@@ -303,10 +304,10 @@ def convert_generic_python_type(
303304
registry: Registry,
304305
parent_type: T.Type = None,
305306
model: T.Type[BaseModel] = None,
306-
) -> Type: # noqa: C901
307+
) -> T.Union[Type[T.Union[BaseType, List]], Placeholder]: # noqa: C901
307308
"""
308309
Convert annotated Python generic types into the most appropriate Graphene
309-
Field type -- e.g. turn `typing.Union` into a Graphene Union.
310+
Field type -- e.g., turn `typing.Union` into a Graphene Union.
310311
"""
311312
origin = type_.__origin__
312313
if not origin: # pragma: no cover # this really should be impossible
@@ -393,7 +394,7 @@ def convert_literal_type(
393394
registry: Registry,
394395
parent_type: T.Type = None,
395396
model: T.Type[BaseModel] = None,
396-
):
397+
) -> T.Union[Type[T.Union[BaseType, List]], Placeholder]:
397398
"""
398399
Convert an annotated Python Literal type into a Graphene Scalar or Union of Scalars.
399400
"""

graphene_pydantic/inputobjecttype.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def __init_subclass_with_meta__(
8080
_meta=None,
8181
**options,
8282
):
83-
assert (
84-
model and issubclass(model, pydantic.BaseModel)
83+
assert model and issubclass(
84+
model, pydantic.BaseModel
8585
), f'You need to pass a valid Pydantic model in {cls.__name__}.Meta, received "{model}"'
8686

8787
assert isinstance(

graphene_pydantic/objecttype.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def __init_subclass_with_meta__(
7171
_meta=None,
7272
**options,
7373
):
74-
assert (
75-
model and issubclass(model, pydantic.BaseModel)
74+
assert model and issubclass(
75+
model, pydantic.BaseModel
7676
), f'You need to pass a valid Pydantic model in {cls.__name__}.Meta, received "{model}"'
7777

7878
assert isinstance(

graphene_pydantic/registry.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from collections import defaultdict
33
from typing import Dict, Generic, Optional, Type, TypeVar, Union
44

5+
from graphene.types.base import BaseType
56
from pydantic import BaseModel
67
from pydantic.fields import FieldInfo
78

@@ -39,7 +40,7 @@ class Registry(Generic[T]):
3940

4041
def __init__(self, required_obj_type: ObjectType):
4142
self._required_obj_type: ObjectType = required_obj_type
42-
self._registry: Dict[ModelType, Output] = {}
43+
self._registry: Dict[ModelType, Union[Type[BaseType], Placeholder]] = {}
4344
self._registry_object_fields: Dict[
4445
ObjectType, Dict[str, FieldInfo]
4546
] = defaultdict(dict)
@@ -52,7 +53,9 @@ def register(self, obj_type: ObjectType):
5253
), "Can't register models linked to another Registry"
5354
self._registry[obj_type._meta.model] = obj_type
5455

55-
def get_type_for_model(self, model: ModelType) -> Optional[Output]:
56+
def get_type_for_model(
57+
self, model: ModelType
58+
) -> Union[Type[BaseType], Placeholder]:
5659
return self._registry.get(model)
5760

5861
def add_placeholder_for_model(self, model: ModelType):

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323
keywords = ["api", "graphql", "protocol", "rest", "relay", "graphene", "pydantic", "model"]
2424

2525
[tool.poetry.dependencies]
26-
python = "^3.7"
26+
python = "^3.8"
2727
graphene = ">=2.1.8"
2828
pydantic = ">=2.0"
2929

0 commit comments

Comments
 (0)