mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-18 12:02:19 +03:00
com2ann: Translate type comments into Python type annotations
This commit is contained in:
parent
45986b18e7
commit
d46332bd94
|
@ -5,13 +5,13 @@ from ..utils.trim_docstring import trim_docstring
|
|||
|
||||
|
||||
class BaseOptions:
|
||||
name = None # type: str
|
||||
description = None # type: str
|
||||
name: str = None
|
||||
description: str = None
|
||||
|
||||
_frozen = False # type: bool
|
||||
_frozen: bool = False
|
||||
|
||||
def __init__(self, class_type):
|
||||
self.class_type = class_type # type: Type
|
||||
self.class_type: Type = class_type
|
||||
|
||||
def freeze(self):
|
||||
self._frozen = True
|
||||
|
|
|
@ -16,7 +16,7 @@ EnumType = type(PyEnum)
|
|||
|
||||
|
||||
class EnumOptions(BaseOptions):
|
||||
enum = None # type: Enum
|
||||
enum: Enum = None
|
||||
deprecation_reason = None
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ if MYPY:
|
|||
|
||||
|
||||
class InputObjectTypeOptions(BaseOptions):
|
||||
fields = None # type: Dict[str, InputField]
|
||||
container = None # type: InputObjectTypeContainer
|
||||
fields: Dict[str, InputField] = None
|
||||
container: InputObjectTypeContainer = None
|
||||
|
||||
|
||||
class InputObjectTypeContainer(dict, BaseType):
|
||||
|
|
|
@ -9,8 +9,8 @@ if MYPY:
|
|||
|
||||
|
||||
class InterfaceOptions(BaseOptions):
|
||||
fields = None # type: Dict[str, Field]
|
||||
interfaces = () # type: Iterable[Type[Interface]]
|
||||
fields: Dict[str, Field] = None
|
||||
interfaces: Iterable[Type[Interface]] = ()
|
||||
|
||||
|
||||
class Interface(BaseType):
|
||||
|
|
|
@ -14,10 +14,10 @@ if MYPY:
|
|||
|
||||
|
||||
class MutationOptions(ObjectTypeOptions):
|
||||
arguments = None # type: Dict[str, Argument]
|
||||
output = None # type: Type[ObjectType]
|
||||
resolver = None # type: Callable
|
||||
interfaces = () # type: Iterable[Type[Interface]]
|
||||
arguments: Dict[str, Argument] = None
|
||||
output: Type[ObjectType] = None
|
||||
resolver: Callable = None
|
||||
interfaces: Iterable[Type[Interface]] = ()
|
||||
|
||||
|
||||
class Mutation(ObjectType):
|
||||
|
|
|
@ -14,8 +14,8 @@ if MYPY:
|
|||
|
||||
|
||||
class ObjectTypeOptions(BaseOptions):
|
||||
fields = None # type: Dict[str, Field]
|
||||
interfaces = () # type: Iterable[Type[Interface]]
|
||||
fields: Dict[str, Field] = None
|
||||
interfaces: Iterable[Type[Interface]] = ()
|
||||
|
||||
|
||||
class ObjectTypeMeta(BaseTypeMeta):
|
||||
|
|
|
@ -121,8 +121,7 @@ class Float(Scalar):
|
|||
"""
|
||||
|
||||
@staticmethod
|
||||
def coerce_float(value):
|
||||
# type: (Any) -> float
|
||||
def coerce_float(value: Any) -> float:
|
||||
try:
|
||||
return float(value)
|
||||
except ValueError:
|
||||
|
|
|
@ -9,7 +9,7 @@ if MYPY:
|
|||
|
||||
|
||||
class UnionOptions(BaseOptions):
|
||||
types = () # type: Iterable[Type[ObjectType]]
|
||||
types: Iterable[Type[ObjectType]] = ()
|
||||
|
||||
|
||||
class Union(UnmountedType, BaseType):
|
||||
|
|
Loading…
Reference in New Issue
Block a user