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:
|
class BaseOptions:
|
||||||
name = None # type: str
|
name: str = None
|
||||||
description = None # type: str
|
description: str = None
|
||||||
|
|
||||||
_frozen = False # type: bool
|
_frozen: bool = False
|
||||||
|
|
||||||
def __init__(self, class_type):
|
def __init__(self, class_type):
|
||||||
self.class_type = class_type # type: Type
|
self.class_type: Type = class_type
|
||||||
|
|
||||||
def freeze(self):
|
def freeze(self):
|
||||||
self._frozen = True
|
self._frozen = True
|
||||||
|
|
|
@ -16,7 +16,7 @@ EnumType = type(PyEnum)
|
||||||
|
|
||||||
|
|
||||||
class EnumOptions(BaseOptions):
|
class EnumOptions(BaseOptions):
|
||||||
enum = None # type: Enum
|
enum: Enum = None
|
||||||
deprecation_reason = None
|
deprecation_reason = None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ if MYPY:
|
||||||
|
|
||||||
|
|
||||||
class InputObjectTypeOptions(BaseOptions):
|
class InputObjectTypeOptions(BaseOptions):
|
||||||
fields = None # type: Dict[str, InputField]
|
fields: Dict[str, InputField] = None
|
||||||
container = None # type: InputObjectTypeContainer
|
container: InputObjectTypeContainer = None
|
||||||
|
|
||||||
|
|
||||||
class InputObjectTypeContainer(dict, BaseType):
|
class InputObjectTypeContainer(dict, BaseType):
|
||||||
|
|
|
@ -9,8 +9,8 @@ if MYPY:
|
||||||
|
|
||||||
|
|
||||||
class InterfaceOptions(BaseOptions):
|
class InterfaceOptions(BaseOptions):
|
||||||
fields = None # type: Dict[str, Field]
|
fields: Dict[str, Field] = None
|
||||||
interfaces = () # type: Iterable[Type[Interface]]
|
interfaces: Iterable[Type[Interface]] = ()
|
||||||
|
|
||||||
|
|
||||||
class Interface(BaseType):
|
class Interface(BaseType):
|
||||||
|
|
|
@ -14,10 +14,10 @@ if MYPY:
|
||||||
|
|
||||||
|
|
||||||
class MutationOptions(ObjectTypeOptions):
|
class MutationOptions(ObjectTypeOptions):
|
||||||
arguments = None # type: Dict[str, Argument]
|
arguments: Dict[str, Argument] = None
|
||||||
output = None # type: Type[ObjectType]
|
output: Type[ObjectType] = None
|
||||||
resolver = None # type: Callable
|
resolver: Callable = None
|
||||||
interfaces = () # type: Iterable[Type[Interface]]
|
interfaces: Iterable[Type[Interface]] = ()
|
||||||
|
|
||||||
|
|
||||||
class Mutation(ObjectType):
|
class Mutation(ObjectType):
|
||||||
|
|
|
@ -14,8 +14,8 @@ if MYPY:
|
||||||
|
|
||||||
|
|
||||||
class ObjectTypeOptions(BaseOptions):
|
class ObjectTypeOptions(BaseOptions):
|
||||||
fields = None # type: Dict[str, Field]
|
fields: Dict[str, Field] = None
|
||||||
interfaces = () # type: Iterable[Type[Interface]]
|
interfaces: Iterable[Type[Interface]] = ()
|
||||||
|
|
||||||
|
|
||||||
class ObjectTypeMeta(BaseTypeMeta):
|
class ObjectTypeMeta(BaseTypeMeta):
|
||||||
|
|
|
@ -121,8 +121,7 @@ class Float(Scalar):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def coerce_float(value):
|
def coerce_float(value: Any) -> float:
|
||||||
# type: (Any) -> float
|
|
||||||
try:
|
try:
|
||||||
return float(value)
|
return float(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
|
@ -9,7 +9,7 @@ if MYPY:
|
||||||
|
|
||||||
|
|
||||||
class UnionOptions(BaseOptions):
|
class UnionOptions(BaseOptions):
|
||||||
types = () # type: Iterable[Type[ObjectType]]
|
types: Iterable[Type[ObjectType]] = ()
|
||||||
|
|
||||||
|
|
||||||
class Union(UnmountedType, BaseType):
|
class Union(UnmountedType, BaseType):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user