Exemple #1
0
 def _check_set_elements(self, node: ast.Set) -> None:
     elements: List[str] = []
     for set_item in node.elts:
         real_set_item = unwrap_unary_node(set_item)
         if isinstance(real_set_item, self._elements_in_sets):
             source = astor.to_source(set_item)
             elements.append(source.strip().strip('(').strip(')'))
     self._report_set_elements(node, elements)
Exemple #2
0
 def _check_if_statement_conditional(self, node: AnyIf) -> None:
     real_node = unwrap_unary_node(node.test)
     if isinstance(real_node, self._forbidden_nodes):
         self.add_violation(WrongConditionalViolation(node))
 def _check_argument_default_values(self, node: AnyFunctionDef) -> None:
     for arg in node.args.defaults:
         real_arg = operators.unwrap_unary_node(arg)
         if not isinstance(real_arg, self._allowed_default_value_types):
             self.add_violation(ComplexDefaultValuesViolation(node))