Skip to content

Commit 69116e9

Browse files
chore: Use Python 3.7-Compatible Type hints (#19)
Co-authored-by: emilkholod <[email protected]>
1 parent 35532b1 commit 69116e9

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

graphene_federation/extend.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Any, Callable
1+
from typing import Any, Callable, Dict
22

33
from graphene import Schema
44

55
from graphene_federation.utils import check_fields_exist_on_type, is_valid_compound_key
66

77

8-
def get_extended_types(schema: Schema) -> dict[str, Any]:
8+
def get_extended_types(schema: Schema) -> Dict[str, Any]:
99
"""
1010
Find all the extended types from the schema.
1111
They can be easily distinguished from the other type as

graphene_federation/inaccessible.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Any, Optional
1+
from typing import Any, Dict, Optional
22

33
from graphene import Schema
44

55
from graphene_federation.utils import get_attributed_fields
66

77

8-
def get_inaccessible_types(schema: Schema) -> dict[str, Any]:
8+
def get_inaccessible_types(schema: Schema) -> Dict[str, Any]:
99
"""
1010
Find all the inaccessible types from the schema.
1111
They can be easily distinguished from the other type as

graphene_federation/requires.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Union
1+
from typing import List, Union
22

33
from graphene import Schema
44

55
from graphene_federation.utils import get_attributed_fields
66

77

8-
def requires(field, fields: Union[str, list[str]]):
8+
def requires(field, fields: Union[str, List[str]]):
99
"""
1010
Mark the required fields for a given field.
1111
The input `fields` can be either a string or a list.

graphene_federation/service.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
from typing import List
23

34
from graphene.types.interface import InterfaceOptions
45
from graphene.types.union import UnionOptions
@@ -31,7 +32,7 @@ def __init__(self, name, field):
3132
self.fields = {name: field}
3233

3334

34-
def convert_fields(schema: Schema, fields: list[str]) -> str:
35+
def convert_fields(schema: Schema, fields: List[str]) -> str:
3536
get_field_name = type_attribute_to_field_name(schema)
3637
return " ".join([get_field_name(field) for field in fields])
3738

graphene_federation/shareable.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from typing import Any, Optional
1+
from typing import Any, Dict, Optional
22

33
from graphene import Schema
44
from graphene.types.interface import InterfaceOptions
55

66
from graphene_federation.utils import get_attributed_fields
77

88

9-
def get_shareable_types(schema: Schema) -> dict[str, Any]:
9+
def get_shareable_types(schema: Schema) -> Dict[str, Any]:
1010
"""
1111
Find all the extended types from the schema.
1212
They can be easily distinguished from the other type as

graphene_federation/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable
1+
from typing import Any, Callable, List, Tuple
22

33
import graphene
44
from graphene import Schema, ObjectType
@@ -43,7 +43,7 @@ def is_valid_compound_key(type_name: str, key: str, schema: Schema):
4343
key_document = parse(f"{{{key}}}")
4444

4545
# List storing tuples of nodes in the key document with its parent types
46-
key_nodes: list[tuple[Any, GrapheneObjectType]] = [
46+
key_nodes: List[Tuple[Any, GrapheneObjectType]] = [
4747
(key_document.definitions[0], schema.graphql_schema.type_map[type_name])
4848
]
4949

0 commit comments

Comments
 (0)