Example #1
0
    def _check_is_magic(self, node: ast.Num) -> None:
        parent = get_parent_ignoring_unary(node)
        if isinstance(parent, self._allowed_parents):
            return

        if node.n in constants.MAGIC_NUMBERS_WHITELIST:
            return

        if isinstance(node.n, int) and node.n <= constants.NON_MAGIC_MODULO:
            return

        self.add_violation(MagicNumberViolation(node, text=str(node.n)))
    def _check_is_magic(self, node: ast.Num) -> None:
        parent = self._get_real_parent(node)
        if isinstance(parent, self._allowed_parents):
            return

        if node.n in MAGIC_NUMBERS_WHITELIST:
            return

        if isinstance(node.n, int) and node.n <= 10:
            return

        self.add_violation(MagicNumberViolation(node, text=str(node.n)))