Skip to content
Permalink
Browse files

Fix linter warnings.

  • Loading branch information...
gwelymernans committed Jul 12, 2019
1 parent b4acb6f commit 21292449bbf85155d068d74ce9c4a6ad948a9626
@@ -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


@@ -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.
@@ -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
@@ -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):
@@ -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:
@@ -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
@@ -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],
@@ -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]

0 comments on commit 2129244

Please sign in to comment.
You can’t perform that action at this time.