How to use the yapf.yapflib.py3compat.lru_cache function in yapf

To help you get started, we’ve selected a few yapf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / yapf / yapf / yapflib / object_state.py View on Github external
  @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
    if not self.parameters:
      return True
    last_param = self.parameters[-1].first_token
    last_token = self.opening_bracket.matching_bracket
    while not last_token.is_comment and last_token.next_token:
      last_token = last_token.next_token
    total_length = last_token.total_length
    total_length -= last_param.total_length - len(last_param.value)
    return total_length + indent <= style.Get('COLUMN_LIMIT')
github google / yapf / yapf / yapflib / format_token.py View on Github external
  @py3compat.lru_cache()
  def is_pseudo_paren(self):
    return hasattr(self.node, 'is_pseudo') and self.node.is_pseudo
github google / yapf / yapf / yapflib / format_token.py View on Github external
  @py3compat.lru_cache()
  def is_name(self):
    return self.node.type == token.NAME and not self.is_keyword
github google / yapf / yapf / yapflib / format_token.py View on Github external
  @py3compat.lru_cache()
  def is_arithmetic_op(self):
    """Token is an arithmetic operator."""
    return self.is_a_expr_op or self.is_m_expr_op
github google / yapf / yapf / yapflib / format_token.py View on Github external
  @py3compat.lru_cache()
  def is_keyword(self):
    return keyword.iskeyword(self.value)
github google / yapf / yapf / yapflib / format_token.py View on Github external
  @py3compat.lru_cache()
  def node_split_penalty(self):
    """Split penalty attached to the pytree node of this token."""
    return pytree_utils.GetNodeAnnotation(
        self.node, pytree_utils.Annotation.SPLIT_PENALTY, default=0)
github google / yapf / yapf / yapflib / format_token.py View on Github external
  @py3compat.lru_cache()
  def name(self):
    """A string representation of the node's name."""
    return pytree_utils.NodeName(self.node)
github google / yapf / yapf / yapflib / format_token.py View on Github external
  @py3compat.lru_cache()
  def is_simple_expr(self):
    """Token is an operator in a simple expression."""
    return Subtype.SIMPLE_EXPRESSION in self.subtypes
github google / yapf / yapf / yapflib / format_token.py View on Github external
  @py3compat.lru_cache()
  def subtypes(self):
    """Extra type information for directing formatting."""
    value = pytree_utils.GetNodeAnnotation(self.node,
                                           pytree_utils.Annotation.SUBTYPE)
    return [Subtype.NONE] if value is None else value
github google / yapf / yapf / yapflib / object_state.py View on Github external
  @py3compat.lru_cache()
  def has_default_values(self):
    return any(param.has_default_value for param in self.parameters)