Skip to content

Commit

Permalink
Fix linter warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwendling committed Jul 12, 2019
1 parent b4acb6f commit 2129244
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion yapf/yapflib/object_state.py
Expand Up @@ -24,7 +24,6 @@

from yapf.yapflib import format_token
from yapf.yapflib import py3compat
from yapf.yapflib import pytree_utils
from yapf.yapflib import style


Expand Down Expand Up @@ -90,6 +89,9 @@ class ParameterListState(object):
Attributes:
opening_bracket: The opening bracket of the parameter list.
closing_bracket: The closing bracket of the parameter list.
has_typed_return: True if the function definition has a typed return.
has_default_values: True if the parameters have default values.
has_split_before_first_param: Whether there is a newline before the first
parameter.
opening_column: The position of the opening parameter before a newline.
Expand Down Expand Up @@ -120,6 +122,7 @@ def has_default_values(self):

@py3compat.lru_cache()
def LastParamFitsOnLine(self, indent):
"""Return true if the last parameter fits on a single line."""
if not self.has_typed_return:
return False
last_param = self.parameters[-1].first_token
Expand Down Expand Up @@ -162,6 +165,7 @@ class Parameter(object):
Attributes:
first_token: (format_token.FormatToken) First token of parameter.
last_token: (format_token.FormatToken) Last token of parameter.
has_default_value: (boolean) True if the parameter has a default value
"""

def __init__(self, first_token, last_token):
Expand All @@ -171,6 +175,7 @@ def __init__(self, first_token, last_token):
@property
@py3compat.lru_cache()
def has_default_value(self):
"""Returns true if the parameter has a default value."""
tok = self.first_token
while tok != self.last_token:
if format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN in tok.subtypes:
Expand Down
2 changes: 1 addition & 1 deletion yapf/yapflib/pytree_unwrapper.py
Expand Up @@ -32,9 +32,9 @@
from lib2to3.pgen2 import token as grammar_token

from yapf.yapflib import format_token
from yapf.yapflib import object_state
from yapf.yapflib import pytree_utils
from yapf.yapflib import pytree_visitor
from yapf.yapflib import object_state
from yapf.yapflib import split_penalty
from yapf.yapflib import style
from yapf.yapflib import unwrapped_line
Expand Down
2 changes: 1 addition & 1 deletion yapf/yapflib/subtype_assigner.py
Expand Up @@ -299,7 +299,7 @@ def Visit_typedargslist(self, node): # pylint: disable=invalid-name
_SetArgListSubtype(node, format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN,
format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST)
tname = False
if not len(node.children):
if not node.children:
return

_AppendFirstLeafTokenSubtype(node.children[0],
Expand Down
2 changes: 1 addition & 1 deletion yapftests/subtype_assigner_test.py
Expand Up @@ -43,7 +43,7 @@ def _CheckFormatTokenSubtypes(self, uwlines, list_of_expected):
self.assertEqual(list_of_expected, actual)

def testFuncDefDefaultAssign(self):
self.maxDiff = None
self.maxDiff = None # pylint: disable=invalid-name
code = textwrap.dedent(r"""
def foo(a=37, *b, **c):
return -x[:42]
Expand Down

0 comments on commit 2129244

Please sign in to comment.