Пример #1
0
    def _check_members_count(self, node: _ModuleMembers) -> None:
        """This method increases the number of module members."""
        if functions.is_method(getattr(node, 'function_type', '')):
            return

        if isinstance(node, FunctionNodes):
            if decorators.has_overload_decorator(node):
                return  # We don't count `@overload` defs as real defs

        if isinstance(get_parent(node), ast.Module):
            self._public_items_count += 1
Пример #2
0
 def _check_getters_setters_methods(self, node: ast.ClassDef) -> None:
     getters_and_setters = set(
         filter(
             lambda getter_setter: functions.is_method(
                 getattr(getter_setter, 'function_type', None), ),
             getters_setters.find_paired_getters_and_setters(node),
         )).union(
             set(  # To delete duplicated violations
                 getters_setters.find_attributed_getters_and_setters(node),
             ))
     for method in getters_and_setters:
         self.add_violation(
             oop.UnpythonicGetterSetterViolation(
                 method,
                 text=method.name,
             ), )
Пример #3
0
    def _check_members_count(self, node: _ModuleMembers) -> None:
        """This method increases the number of module members."""
        is_real_method = is_method(getattr(node, 'function_type', None))

        if isinstance(get_parent(node), ast.Module) and not is_real_method:
            self._public_items_count += 1