diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f30010f9..e7b8b1a4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,24 @@ repos: - repo: git://github.com/pre-commit/pre-commit-hooks - rev: v1.3.0 + rev: v2.1.0 hooks: + - id: check-merge-conflict - id: check-json - id: check-yaml - id: debug-statements - id: end-of-file-fixer exclude: ^docs/.*$ - - id: trailing-whitespace - exclude: README.md - id: pretty-format-json args: - --autofix + - id: trailing-whitespace + exclude: README.md - repo: https://github.com/asottile/pyupgrade - rev: v1.4.0 + rev: v1.12.0 hooks: - id: pyupgrade - repo: https://github.com/ambv/black - rev: 18.6b4 + rev: 18.9b0 hooks: - id: black - language_version: python3.6 + language_version: python3 diff --git a/graphql/execution/utils.py b/graphql/execution/utils.py index b1e7ff25..d4fe4f7a 100644 --- a/graphql/execution/utils.py +++ b/graphql/execution/utils.py @@ -121,11 +121,15 @@ def __init__( self.variable_values = variable_values self.errors = errors self.context_value = context_value - self.argument_values_cache = {} # type: Dict[Tuple[GraphQLField, Field], Dict[str, Any]] + self.argument_values_cache = ( + {} + ) # type: Dict[Tuple[GraphQLField, Field], Dict[str, Any]] self.executor = executor self.middleware = middleware self.allow_subscriptions = allow_subscriptions - self._subfields_cache = {} # type: Dict[Tuple[GraphQLObjectType, Tuple[Field, ...]], DefaultOrderedDict] + self._subfields_cache = ( + {} + ) # type: Dict[Tuple[GraphQLObjectType, Tuple[Field, ...]], DefaultOrderedDict] def get_field_resolver(self, field_resolver): # type: (Callable) -> Callable diff --git a/graphql/language/lexer.py b/graphql/language/lexer.py index a60bc6e2..45cd6683 100644 --- a/graphql/language/lexer.py +++ b/graphql/language/lexer.py @@ -245,7 +245,7 @@ def position_after_whitespace(body, start_position): def read_number(source, start, first_code): # type: (Source, int, Optional[int]) -> Token - """Reads a number token from the source file, either a float + r"""Reads a number token from the source file, either a float or an int depending on whether a decimal point appears. Int: -?(0|[1-9][0-9]*) diff --git a/graphql/utils/type_info.py b/graphql/utils/type_info.py index 76433eb6..f3862f30 100644 --- a/graphql/utils/type_info.py +++ b/graphql/utils/type_info.py @@ -60,8 +60,12 @@ def __init__(self, schema, get_field_def_fn=get_field_def): # type: (GraphQLSchema, Callable) -> None self._schema = schema self._type_stack = [] # type: List[Optional[GraphQLType]] - self._parent_type_stack = [] # type: List[Union[GraphQLInterfaceType, GraphQLObjectType, None]] - self._input_type_stack = [] # type: List[Optional[Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType, None]]] + self._parent_type_stack = ( + [] + ) # type: List[Union[GraphQLInterfaceType, GraphQLObjectType, None]] + self._input_type_stack = ( + [] + ) # type: List[Optional[Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType, None]]] self._field_def_stack = [] # type: List[Optional[GraphQLField]] self._directive = None # type: Optional[GraphQLDirective] self._argument = None # type: Optional[GraphQLArgument] diff --git a/graphql/validation/rules/overlapping_fields_can_be_merged.py b/graphql/validation/rules/overlapping_fields_can_be_merged.py index 8506e2cd..08f40f1b 100644 --- a/graphql/validation/rules/overlapping_fields_can_be_merged.py +++ b/graphql/validation/rules/overlapping_fields_can_be_merged.py @@ -47,7 +47,9 @@ def __init__(self, context): # A cache for the "field map" and list of fragment names found in any given # selection set. Selection sets may be asked for this information multiple # times, so this improves the performance of this validator. - self._cached_fields_and_fragment_names = {} # type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]] + self._cached_fields_and_fragment_names = ( + {} + ) # type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]] def leave_SelectionSet( self, diff --git a/graphql/validation/validation.py b/graphql/validation/validation.py index ed647742..ed6c520b 100644 --- a/graphql/validation/validation.py +++ b/graphql/validation/validation.py @@ -86,9 +86,13 @@ def __init__(self, schema, ast, type_info): self._errors = [] # type: List[GraphQLError] self._fragments = None # type: Optional[Dict[str, FragmentDefinition]] self._fragment_spreads = {} # type: Dict[Node, List[FragmentSpread]] - self._recursively_referenced_fragments = {} # type: Dict[OperationDefinition, List[FragmentSpread]] + self._recursively_referenced_fragments = ( + {} + ) # type: Dict[OperationDefinition, List[FragmentSpread]] self._variable_usages = {} # type: Dict[Node, List[VariableUsage]] - self._recursive_variable_usages = {} # type: Dict[OperationDefinition, List[VariableUsage]] + self._recursive_variable_usages = ( + {} + ) # type: Dict[OperationDefinition, List[VariableUsage]] def report_error(self, error): self._errors.append(error)