Skip to content

Commit

Permalink
Remove result type annotation from __init__ methods
Browse files Browse the repository at this point in the history
They are noisy and not needed in mypy any more (python/mypy#5677).
  • Loading branch information
Cito committed Jan 25, 2020
1 parent 1a42027 commit 1ff3e96
Show file tree
Hide file tree
Showing 36 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/graphql/execution/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MiddlewareManager:
_cached_resolvers: Dict[GraphQLFieldResolver, GraphQLFieldResolver]
_middleware_resolvers: Optional[List[Callable]]

def __init__(self, *middlewares: Any) -> None:
def __init__(self, *middlewares: Any):
self.middlewares = middlewares
self._middleware_resolvers = (
list(get_middleware_resolvers(middlewares)) if middlewares else None
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/language/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Lexer:
EOF token whenever called.
"""

def __init__(self, source: Source) -> None:
def __init__(self, source: Source):
"""Given a Source object, initialize a Lexer for that source."""
self.source = source
self.token = self.last_token = Token(TokenKind.SOF, 0, 0, 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/language/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class ParallelVisitor(Visitor):
If a prior visitor edits a node, no following visitors will see that node.
"""

def __init__(self, visitors: Collection[Visitor]) -> None:
def __init__(self, visitors: Collection[Visitor]):
"""Create a new visitor from the given list of parallel visitors."""
self.visitors = visitors
self.skipping: List[Any] = [None] * len(visitors)
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/pyutils/event_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class EventEmitter:
"""A very simple EventEmitter."""

def __init__(self, loop: Optional[AbstractEventLoop] = None) -> None:
def __init__(self, loop: Optional[AbstractEventLoop] = None):
self.loop = loop
self.listeners: Dict[str, List[Callable]] = defaultdict(list)

Expand Down Expand Up @@ -43,7 +43,7 @@ class EventEmitterAsyncIterator:
Useful for mocking a PubSub system for tests.
"""

def __init__(self, event_emitter: EventEmitter, event_name: str) -> None:
def __init__(self, event_emitter: EventEmitter, event_name: str):
self.queue: Queue = Queue(loop=cast(AbstractEventLoop, event_emitter.loop))
event_emitter.add_listener(event_name, self.queue.put)
self.remove_listener = lambda: event_emitter.remove_listener(
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/type/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class GraphQLWrappingType(GraphQLType, Generic[GT]):

of_type: GT

def __init__(self, type_: GT) -> None:
def __init__(self, type_: GT):
if not is_type(type_):
raise TypeError(
f"Can only create a wrapper for a GraphQLType, but got: {type_}."
Expand Down Expand Up @@ -1415,7 +1415,7 @@ def fields(self):
}
"""

def __init__(self, type_: GT) -> None:
def __init__(self, type_: GT):
super().__init__(type_=type_)

def __str__(self):
Expand Down Expand Up @@ -1455,7 +1455,7 @@ class RowType(GraphQLObjectType):
Note: the enforcement of non-nullability occurs within the executor.
"""

def __init__(self, type_: GNT) -> None:
def __init__(self, type_: GNT):
super().__init__(type_=type_)
if isinstance(type_, GraphQLNonNull):
raise TypeError(
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/type/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SchemaValidationContext:
errors: List[GraphQLError]
schema: GraphQLSchema

def __init__(self, schema: GraphQLSchema) -> None:
def __init__(self, schema: GraphQLSchema):
self.errors = []
self.schema = schema

Expand Down Expand Up @@ -500,7 +500,7 @@ def get_operation_type_node(
class InputObjectCircularRefsValidator:
"""Modified copy of algorithm from validation.rules.NoFragmentCycles"""

def __init__(self, context: SchemaValidationContext) -> None:
def __init__(self, context: SchemaValidationContext):
self.context = context
# Tracks already visited types to maintain O(N) and to ensure that cycles
# are not redundantly reported.
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/utilities/find_deprecated_usages.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FindDeprecatedUsages(Visitor):
type_info: TypeInfo
errors: List[GraphQLError]

def __init__(self, type_info: TypeInfo) -> None:
def __init__(self, type_info: TypeInfo):
super().__init__()
self.type_info = type_info
self.errors = []
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/utilities/type_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def get_field_def(
class TypeInfoVisitor(Visitor):
"""A visitor which maintains a provided TypeInfo."""

def __init__(self, type_info: "TypeInfo", visitor: Visitor) -> None:
def __init__(self, type_info: "TypeInfo", visitor: Visitor):
self.type_info = type_info
self.visitor = visitor

Expand Down
6 changes: 3 additions & 3 deletions src/graphql/validation/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ASTValidationRule(Visitor):

context: ASTValidationContext

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
self.context = context

def report_error(self, error: GraphQLError):
Expand All @@ -30,7 +30,7 @@ class SDLValidationRule(ASTValidationRule):

context: ValidationContext

def __init__(self, context: SDLValidationContext) -> None:
def __init__(self, context: SDLValidationContext):
super().__init__(context)


Expand All @@ -39,7 +39,7 @@ class ValidationRule(ASTValidationRule):

context: ValidationContext

def __init__(self, context: ValidationContext) -> None:
def __init__(self, context: ValidationContext):
super().__init__(context)


Expand Down
4 changes: 2 additions & 2 deletions src/graphql/validation/rules/known_argument_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class KnownArgumentNamesOnDirectivesRule(ASTValidationRule):

context: Union[ValidationContext, SDLValidationContext]

def __init__(self, context: Union[ValidationContext, SDLValidationContext]) -> None:
def __init__(self, context: Union[ValidationContext, SDLValidationContext]):
super().__init__(context)
directive_args: Dict[str, List[str]] = {}

Expand Down Expand Up @@ -64,7 +64,7 @@ class KnownArgumentNamesRule(KnownArgumentNamesOnDirectivesRule):

context: ValidationContext

def __init__(self, context: ValidationContext) -> None:
def __init__(self, context: ValidationContext):
super().__init__(context)

def enter_argument(self, arg_node: ArgumentNode, *args):
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/known_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class KnownDirectivesRule(ASTValidationRule):

context: Union[ValidationContext, SDLValidationContext]

def __init__(self, context: Union[ValidationContext, SDLValidationContext]) -> None:
def __init__(self, context: Union[ValidationContext, SDLValidationContext]):
super().__init__(context)
locations_map: Dict[str, List[DirectiveLocation]] = {}

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/known_type_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class KnownTypeNamesRule(ASTValidationRule):
definitions and fragment conditions) are defined by the type schema.
"""

def __init__(self, context: Union[ValidationContext, SDLValidationContext]) -> None:
def __init__(self, context: Union[ValidationContext, SDLValidationContext]):
super().__init__(context)
schema = context.schema
self.existing_types_map = schema.type_map if schema else {}
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/lone_anonymous_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LoneAnonymousOperationRule(ASTValidationRule):
(the query short-hand) that it contains only that one operation definition.
"""

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
super().__init__(context)
self.operation_count = 0

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/lone_schema_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LoneSchemaDefinitionRule(SDLValidationRule):
A GraphQL document is only valid if it contains only one schema definition.
"""

def __init__(self, context: SDLValidationContext) -> None:
def __init__(self, context: SDLValidationContext):
super().__init__(context)
old_schema = context.schema
self.already_defined = old_schema and (
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/no_fragment_cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class NoFragmentCyclesRule(ASTValidationRule):
"""No fragment cycles"""

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
super().__init__(context)
# Tracks already visited fragments to maintain O(N) and to ensure that
# cycles are not redundantly reported.
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/no_undefined_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NoUndefinedVariablesRule(ValidationRule):
via fragment spreads, are defined by that operation.
"""

def __init__(self, context: ValidationContext) -> None:
def __init__(self, context: ValidationContext):
super().__init__(context)
self.defined_variable_names: Set[str] = set()

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/no_unused_fragments.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NoUnusedFragmentsRule(ASTValidationRule):
operations, or spread within other fragments spread within operations.
"""

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
super().__init__(context)
self.operation_defs: List[OperationDefinitionNode] = []
self.fragment_defs: List[FragmentDefinitionNode] = []
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/no_unused_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NoUnusedVariablesRule(ValidationRule):
either directly or within a spread fragment.
"""

def __init__(self, context: ValidationContext) -> None:
def __init__(self, context: ValidationContext):
super().__init__(context)
self.variable_defs: List[VariableDefinitionNode] = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class OverlappingFieldsCanBeMergedRule(ValidationRule):
either correspond to distinct response names or can be merged without ambiguity.
"""

def __init__(self, context: ValidationContext) -> None:
def __init__(self, context: ValidationContext):
super().__init__(context)
# A memoization for when two fragments are compared "between" each other for
# conflicts. Two fragments may be compared many times, so memoizing this can
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/possible_type_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PossibleTypeExtensionsRule(SDLValidationRule):
A type extension is only valid if the type is defined and has the same kind.
"""

def __init__(self, context: SDLValidationContext) -> None:
def __init__(self, context: SDLValidationContext):
super().__init__(context)
self.schema = context.schema
self.defined_types = {
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/validation/rules/provided_required_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProvidedRequiredArgumentsOnDirectivesRule(ASTValidationRule):

context: Union[ValidationContext, SDLValidationContext]

def __init__(self, context: Union[ValidationContext, SDLValidationContext]) -> None:
def __init__(self, context: Union[ValidationContext, SDLValidationContext]):
super().__init__(context)
required_args_map: Dict[
str, Dict[str, Union[GraphQLArgument, InputValueDefinitionNode]]
Expand Down Expand Up @@ -92,7 +92,7 @@ class ProvidedRequiredArgumentsRule(ProvidedRequiredArgumentsOnDirectivesRule):

context: ValidationContext

def __init__(self, context: ValidationContext) -> None:
def __init__(self, context: ValidationContext):
super().__init__(context)

def leave_field(self, field_node: FieldNode, *_args):
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_argument_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UniqueArgumentNamesRule(ASTValidationRule):
named.
"""

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
super().__init__(context)
self.known_arg_names: Dict[str, NameNode] = {}

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_directive_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UniqueDirectiveNamesRule(SDLValidationRule):
A GraphQL document is only valid if all defined directives have unique names.
"""

def __init__(self, context: SDLValidationContext) -> None:
def __init__(self, context: SDLValidationContext):
super().__init__(context)
self.known_directive_names: Dict[str, NameNode] = {}
self.schema = context.schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UniqueDirectivesPerLocationRule(ASTValidationRule):

context: Union[ValidationContext, SDLValidationContext]

def __init__(self, context: Union[ValidationContext, SDLValidationContext]) -> None:
def __init__(self, context: Union[ValidationContext, SDLValidationContext]):
super().__init__(context)
unique_directive_map: Dict[str, bool] = {}

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_enum_value_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UniqueEnumValueNamesRule(SDLValidationRule):
A GraphQL enum type is only valid if all its values are uniquely named.
"""

def __init__(self, context: SDLValidationContext) -> None:
def __init__(self, context: SDLValidationContext):
super().__init__(context)
schema = context.schema
self.existing_type_map = schema.type_map if schema else {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UniqueFieldDefinitionNamesRule(SDLValidationRule):
A GraphQL complex type is only valid if all its fields are uniquely named.
"""

def __init__(self, context: SDLValidationContext) -> None:
def __init__(self, context: SDLValidationContext):
super().__init__(context)
schema = context.schema
self.existing_type_map = schema.type_map if schema else {}
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_fragment_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UniqueFragmentNamesRule(ASTValidationRule):
A GraphQL document is only valid if all defined fragments have unique names.
"""

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
super().__init__(context)
self.known_fragment_names: Dict[str, NameNode] = {}

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_input_field_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UniqueInputFieldNamesRule(ASTValidationRule):
named.
"""

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
super().__init__(context)
self.known_names_stack: List[Dict[str, NameNode]] = []
self.known_names: Dict[str, NameNode] = {}
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_operation_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UniqueOperationNamesRule(ASTValidationRule):
A GraphQL document is only valid if all defined operations have unique names.
"""

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
super().__init__(context)
self.known_operation_names: Dict[str, NameNode] = {}

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_operation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UniqueOperationTypesRule(SDLValidationRule):
A GraphQL document is only valid if it has only one type per operation.
"""

def __init__(self, context: SDLValidationContext) -> None:
def __init__(self, context: SDLValidationContext):
super().__init__(context)
schema = context.schema
self.defined_operation_types: Dict[
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_type_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UniqueTypeNamesRule(SDLValidationRule):
A GraphQL document is only valid if all defined types have unique names.
"""

def __init__(self, context: SDLValidationContext) -> None:
def __init__(self, context: SDLValidationContext):
super().__init__(context)
self.known_type_names: Dict[str, NameNode] = {}
self.schema = context.schema
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/rules/unique_variable_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UniqueVariableNamesRule(ASTValidationRule):
A GraphQL operation is only valid if all its variables are uniquely named.
"""

def __init__(self, context: ASTValidationContext) -> None:
def __init__(self, context: ASTValidationContext):
super().__init__(context)
self.known_variable_names: Dict[str, NameNode] = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class VariablesInAllowedPositionRule(ValidationRule):
"""Variables passed to field arguments conform to type"""

def __init__(self, context: ValidationContext) -> None:
def __init__(self, context: ValidationContext):
super().__init__(context)
self.var_def_map: Dict[str, Any] = {}

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/validation_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VariableUsageVisitor(Visitor):

usages: List[VariableUsage]

def __init__(self, type_info: TypeInfo) -> None:
def __init__(self, type_info: TypeInfo):
self.usages = []
self._append_usage = self.usages.append
self._type_info = type_info
Expand Down
2 changes: 1 addition & 1 deletion tests/execution/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class Barrier:
"""Barrier that makes progress only after a certain number of waits."""

def __init__(self, number: int) -> None:
def __init__(self, number: int):
self.event = asyncio.Event()
self.number = number

Expand Down
2 changes: 1 addition & 1 deletion tests/test_user_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MutationEnum(Enum):
class UserRegistry:
""""Simulation of a user registry with asynchronous database backend access."""

def __init__(self, **users) -> None:
def __init__(self, **users):
self._registry: Dict[str, User] = users
self._emitter = EventEmitter()

Expand Down

0 comments on commit 1ff3e96

Please sign in to comment.