Skip to content

Commit

Permalink
fix: downgrade to 3.8-compatible type hints (#10)
Browse files Browse the repository at this point in the history
fixes #9
  • Loading branch information
mahdyhamad authored Jan 30, 2023
1 parent b8bf51b commit 4fe6404
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions graphene_federation/entity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any, Callable
from typing import Any, Callable, Dict

from graphene import List, NonNull, Union

Expand All @@ -11,7 +11,7 @@
from .utils import field_name_to_type_attribute


def get_entities(schema: Schema) -> dict[str, Any]:
def get_entities(schema: Schema) -> Dict[str, Any]:
"""
Find all the entities from the type map.
They can be easily distinguished from the other type as
Expand All @@ -27,7 +27,7 @@ def get_entities(schema: Schema) -> dict[str, Any]:
return entities


def get_entity_cls(entities: dict[str, Any]) -> Union:
def get_entity_cls(entities: Dict[str, Any]) -> Union:
"""
Create _Entity type which is a union of all the entities types.
"""
Expand Down
6 changes: 3 additions & 3 deletions graphene_federation/extend.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any, Callable, Union
from typing import Any, Callable, Union, Dict, List

from graphene import Schema


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
Expand Down Expand Up @@ -54,7 +54,7 @@ def external(field):
return field


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.
Expand Down
6 changes: 3 additions & 3 deletions graphene_federation/provides.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Any, Union
from typing import Any, Union, Dict, List

from graphene import Field
from graphene import Schema


def get_provides_parent_types(schema: Schema) -> dict[str, Any]:
def get_provides_parent_types(schema: Schema) -> Dict[str, Any]:
"""
Find all the types for which a field is provided from the schema.
They can be easily distinguished from the other type as
Expand All @@ -19,7 +19,7 @@ def get_provides_parent_types(schema: Schema) -> dict[str, Any]:
return provides_parent_types


def provides(field, fields: Union[str, list[str]] = None):
def provides(field, fields: Union[str, List[str]] = None):
"""
:param field: base type (when used as decorator) or field of base type
Expand Down
4 changes: 3 additions & 1 deletion graphene_federation/service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import re

from typing import List

from graphql.utilities.print_schema import print_fields

from graphene import ObjectType, String, Field, Schema
Expand All @@ -21,7 +23,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])

Expand Down

0 comments on commit 4fe6404

Please sign in to comment.