Skip to content

Commit

Permalink
Fix flake8 F401 violations (unused imports) (graphql-python#233)
Browse files Browse the repository at this point in the history
Fix flake8 F401 violations (unused imports)
  • Loading branch information
dan98765 authored Mar 17, 2019
1 parent 9d558c3 commit 8f7c8f3
Show file tree
Hide file tree
Showing 22 changed files with 24 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ repos:
rev: 3.7.7
hooks:
- id: flake8
exclude: (^docs/.*$|^scripts/generate_ast.py$|test_.*$)
exclude: test_.*$
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import sys
import os
import shlex

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
3 changes: 0 additions & 3 deletions graphql/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from .decider import GraphQLDeciderBackend
from .cache import GraphQLCachedBackend

# Necessary for static type checking
if False: # flake8: noqa
from typing import Union

_default_backend = None

Expand Down
2 changes: 1 addition & 1 deletion graphql/backend/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Necessary for static type checking
if False: # flake8: noqa
from typing import Any, Dict, Optional, Union, Tuple, Hashable
from typing import Dict, Optional, Hashable
from .base import GraphQLDocument

_cached_schemas = {} # type: Dict[GraphQLSchema, str]
Expand Down
2 changes: 1 addition & 1 deletion graphql/backend/decider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Necessary for static type checking
if False: # flake8: noqa
from typing import List, Union, Any, Optional, Hashable, Dict, Tuple, Type
from typing import List, Union, Optional, Hashable, Dict, Tuple, Type
from ..type.schema import GraphQLSchema


Expand Down
2 changes: 1 addition & 1 deletion graphql/error/format_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Necessary for static type checking
if False: # flake8: noqa
from typing import Any, Dict, Union
from typing import Any, Dict


def format_error(error):
Expand Down
2 changes: 1 addition & 1 deletion graphql/execution/executors/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
if False: # flake8: noqa
from ..base import ResolveInfo
from promise import Promise
from typing import Callable, Dict, Tuple, Union, Any
from typing import Callable, Dict, Tuple, Any


def process(
Expand Down
5 changes: 2 additions & 3 deletions graphql/execution/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
from functools import partial
from itertools import chain

from promise import Promise, promisify
from promise import promisify

# Necessary for static type checking
if False: # flake8: noqa
from .base import ResolveInfo
from typing import Any, Callable, Iterator, Tuple, Union, List, Dict, Iterable
from typing import Any, Callable, Iterator, Tuple, Dict, Iterable

MIDDLEWARE_RESOLVER_FUNCTION = "resolve"

Expand Down
2 changes: 1 addition & 1 deletion graphql/language/ast.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Necessary for static type checking
if False: # flake8: noqa
from .parser import Loc
from typing import Any, Optional, Union, List, Tuple, Iterable
from typing import Any, Optional, Union, List, Iterable

# This is autogenerated code. DO NOT change this manually.
# Run scripts/generate_ast.py to generate this file.
Expand Down
41 changes: 2 additions & 39 deletions graphql/language/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,8 @@

# Necessary for static type checking
if False: # flake8: noqa
from typing import Any, List, Optional, Union
from graphql.language.ast import (
Node,
Name,
Variable,
Document,
OperationDefinition,
VariableDefinition,
SelectionSet,
Field,
Argument,
FragmentSpread,
InlineFragment,
FragmentDefinition,
IntValue,
StringValue,
BooleanValue,
EnumValue,
ListValue,
ObjectValue,
ObjectField,
Directive,
NamedType,
ListType,
NonNullType,
SchemaDefinition,
OperationTypeDefinition,
ScalarTypeDefinition,
ObjectTypeDefinition,
FieldDefinition,
InputValueDefinition,
InterfaceTypeDefinition,
UnionTypeDefinition,
EnumTypeDefinition,
EnumValueDefinition,
InputObjectTypeDefinition,
TypeExtensionDefinition,
DirectiveDefinition,
)
from typing import Any, List, Optional
from graphql.language.ast import Node

__all__ = ["print_ast"]

Expand Down
11 changes: 4 additions & 7 deletions graphql/language/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
if False: # flake8: noqa
from typing import Any, List, Optional, Union, Tuple, Dict
from ..utils.type_info import TypeInfo
from ..validation.validation import UsageVisitor
from .ast import Node, Document, OperationDefinition
from .printer import PrintingVisitor


class _Falsey(object):
Expand Down Expand Up @@ -44,17 +41,17 @@ def __init__(self, in_array, index, keys, edits, prev):


def visit(root, visitor, key_map=None):
# type: (Union[Node, List[Node]], Visitor, Optional[Dict[Node, Tuple]]) -> Any
# type: (Union[ast.Node, List[ast.Node]], Visitor, Optional[Dict[ast.Node, Tuple]]) -> Any
visitor_keys = key_map or QUERY_DOCUMENT_KEYS

stack = None # type: Optional[Stack]
in_array = isinstance(root, list)
keys = [root]
index = -1
edits = [] # type: List[Tuple[Union[str, int], Any]]
parent = None # type: Optional[Node]
parent = None # type: Optional[ast.Node]
path = [] # type: List
ancestors = [] # type: List[Node]
ancestors = [] # type: List[ast.Node]
new_root = root
leave = visitor.leave
enter = visitor.enter
Expand Down Expand Up @@ -214,7 +211,7 @@ def __init__(self, visitors):
self.visitors = visitors
self.skipping = [None] * len(
visitors
) # type: List[Union[Node, _Break, _Falsey, None]]
) # type: List[Union[ast.Node, _Break, _Falsey, None]]
return None

def enter(
Expand Down
2 changes: 1 addition & 1 deletion graphql/pyutils/contain_subset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Necessary for static type checking
if False: # flake8: noqa
from typing import Any, Dict
from typing import Any

obj = (dict, list, tuple)

Expand Down
2 changes: 1 addition & 1 deletion graphql/pyutils/default_ordered_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Necessary for static type checking
if False: # flake8: noqa
from typing import Any, List
from typing import Any


class DefaultOrderedDict(OrderedDict):
Expand Down
2 changes: 1 addition & 1 deletion graphql/type/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
GraphQLUnionType,
GraphQLType,
)
from typing import Dict, Union, Any, List, Optional
from typing import Dict, Union, List, Optional


class GraphQLSchema(object):
Expand Down
2 changes: 1 addition & 1 deletion graphql/type/typemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Necessary for static type checking
if False: # flake8: noqa
from ..type.definition import GraphQLNamedType
from typing import Any, List, Optional, Union, Dict, Set, Mapping, DefaultDict
from typing import List, Union, Dict, Set, DefaultDict


class GraphQLTypeMap(OrderedDict):
Expand Down
1 change: 0 additions & 1 deletion graphql/utils/schema_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
GraphQLArgument,
GraphQLType,
GraphQLField,
GraphQLInputObjectField,
GraphQLEnumValue,
)
from ..type.schema import GraphQLSchema
Expand Down
2 changes: 1 addition & 1 deletion graphql/utils/type_from_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..language.ast import ListType, NamedType, NonNullType
from ..type.definition import GraphQLNamedType
from ..type.schema import GraphQLSchema
from typing import Any, Union
from typing import Union


def type_from_ast(schema, type_node):
Expand Down
2 changes: 1 addition & 1 deletion graphql/utils/value_from_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if False: # flake8: noqa
from ..language.ast import Node
from ..type.definition import GraphQLType
from typing import Any, Dict, Union, Optional, List
from typing import Dict, Union, Optional, List


def value_from_ast(value_ast, type, variables=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
InlineFragment,
SelectionSet,
)
from ...type.definition import GraphQLUnionType, GraphQLField, GraphQLScalarType
from ...type.definition import GraphQLField, GraphQLScalarType
from typing import List, Union, Any, Optional, Dict, Tuple


Expand Down
3 changes: 0 additions & 3 deletions graphql/validation/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
from ..error import GraphQLError
from .rules.base import ValidationRule
from ..type.definition import (
GraphQLList,
GraphQLObjectType,
GraphQLScalarType,
GraphQLInterfaceType,
GraphQLUnionType,
GraphQLField,
GraphQLArgument,
GraphQLType,
Expand Down
4 changes: 2 additions & 2 deletions scripts/generate_ast.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from casing import snake

if __name__ == "__main__":
import os.path
import sys
Expand All @@ -14,8 +16,6 @@
sys.exit(process.wait())


from casing import snake

# Fix inconsistencies between libgraphqlparser and graphql-js
REMAP_TYPES = {"ArrayValue": "ListValue"}

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
[flake8]
# Must match black formatter default line length
max-line-length = 88
ignore = F401,E203,E501,W503,W504
ignore = E203,E501,W503,W504

0 comments on commit 8f7c8f3

Please sign in to comment.