From 69116e9881dcf85156caaf3826a240de33571357 Mon Sep 17 00:00:00 2001 From: emilkholod Date: Wed, 24 May 2023 06:37:26 +0500 Subject: [PATCH 1/2] chore: Use Python 3.7-Compatible Type hints (#19) Co-authored-by: emilkholod --- graphene_federation/extend.py | 4 ++-- graphene_federation/inaccessible.py | 4 ++-- graphene_federation/requires.py | 4 ++-- graphene_federation/service.py | 3 ++- graphene_federation/shareable.py | 4 ++-- graphene_federation/utils.py | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/graphene_federation/extend.py b/graphene_federation/extend.py index 209e398..c6fb972 100644 --- a/graphene_federation/extend.py +++ b/graphene_federation/extend.py @@ -1,11 +1,11 @@ -from typing import Any, Callable +from typing import Any, Callable, Dict from graphene import Schema from graphene_federation.utils import check_fields_exist_on_type, is_valid_compound_key -def get_extended_types(schema: Schema) -> dict[str, Any]: +def get_extended_types(schema: Schema) -> Dict[str, Any]: """ Find all the extended types from the schema. They can be easily distinguished from the other type as diff --git a/graphene_federation/inaccessible.py b/graphene_federation/inaccessible.py index 24fa2ff..fffc44a 100644 --- a/graphene_federation/inaccessible.py +++ b/graphene_federation/inaccessible.py @@ -1,11 +1,11 @@ -from typing import Any, Optional +from typing import Any, Dict, Optional from graphene import Schema from graphene_federation.utils import get_attributed_fields -def get_inaccessible_types(schema: Schema) -> dict[str, Any]: +def get_inaccessible_types(schema: Schema) -> Dict[str, Any]: """ Find all the inaccessible types from the schema. They can be easily distinguished from the other type as diff --git a/graphene_federation/requires.py b/graphene_federation/requires.py index 63968ac..e270e5b 100644 --- a/graphene_federation/requires.py +++ b/graphene_federation/requires.py @@ -1,11 +1,11 @@ -from typing import Union +from typing import List, Union from graphene import Schema from graphene_federation.utils import get_attributed_fields -def requires(field, fields: Union[str, list[str]]): +def requires(field, fields: Union[str, List[str]]): """ Mark the required fields for a given field. The input `fields` can be either a string or a list. diff --git a/graphene_federation/service.py b/graphene_federation/service.py index 2a22ca6..786ea19 100644 --- a/graphene_federation/service.py +++ b/graphene_federation/service.py @@ -1,4 +1,5 @@ import re +from typing import List from graphene.types.interface import InterfaceOptions from graphene.types.union import UnionOptions @@ -31,7 +32,7 @@ def __init__(self, name, field): self.fields = {name: field} -def convert_fields(schema: Schema, fields: list[str]) -> str: +def convert_fields(schema: Schema, fields: List[str]) -> str: get_field_name = type_attribute_to_field_name(schema) return " ".join([get_field_name(field) for field in fields]) diff --git a/graphene_federation/shareable.py b/graphene_federation/shareable.py index 2267e18..29634f6 100644 --- a/graphene_federation/shareable.py +++ b/graphene_federation/shareable.py @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any, Dict, Optional from graphene import Schema from graphene.types.interface import InterfaceOptions @@ -6,7 +6,7 @@ from graphene_federation.utils import get_attributed_fields -def get_shareable_types(schema: Schema) -> dict[str, Any]: +def get_shareable_types(schema: Schema) -> Dict[str, Any]: """ Find all the extended types from the schema. They can be easily distinguished from the other type as diff --git a/graphene_federation/utils.py b/graphene_federation/utils.py index 6cf8d1e..917ce52 100644 --- a/graphene_federation/utils.py +++ b/graphene_federation/utils.py @@ -1,4 +1,4 @@ -from typing import Any, Callable +from typing import Any, Callable, List, Tuple import graphene from graphene import Schema, ObjectType @@ -43,7 +43,7 @@ def is_valid_compound_key(type_name: str, key: str, schema: Schema): key_document = parse(f"{{{key}}}") # List storing tuples of nodes in the key document with its parent types - key_nodes: list[tuple[Any, GrapheneObjectType]] = [ + key_nodes: List[Tuple[Any, GrapheneObjectType]] = [ (key_document.definitions[0], schema.graphql_schema.type_map[type_name]) ] From 07f42cee52ee7b98385aaa62ed47929dd79ccd56 Mon Sep 17 00:00:00 2001 From: Erik Wrede Date: Wed, 24 May 2023 03:37:49 +0200 Subject: [PATCH 2/2] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index dc9f67c..a0d56bd 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() -version = '3.1.3' +version = '3.1.4' tests_require = [ "pytest==7.1.2",