def _check_float_key(self, node: ast.Subscript) -> None: is_float_key = ( isinstance(node.slice, ast.Index) and self._is_float_key(node.slice) ) if is_float_key: self.add_violation(best_practices.FloatKeyViolation(node))
def _check_float_keys(self, keys: _HashItems) -> None: for dict_key in keys: if dict_key is None: continue real_key = operators.unwrap_unary_node(dict_key) is_float_key = (isinstance(real_key, ast.Num) and isinstance(real_key.n, float)) if is_float_key: self.add_violation(best_practices.FloatKeyViolation(dict_key))
def _check_float_keys(self, keys: _HashItems) -> None: for dict_key in keys: if dict_key is None: continue evaluates_to_float = False if isinstance(dict_key, ast.BinOp): evaluated_key = getattr(dict_key, 'wps_op_eval', None) evaluates_to_float = isinstance(evaluated_key, float) real_key = operators.unwrap_unary_node(dict_key) is_float_key = (isinstance(real_key, ast.Num) and isinstance(real_key.n, float)) if is_float_key or evaluates_to_float: self.add_violation(best_practices.FloatKeyViolation(dict_key))
def _check_float_key(self, node: ast.Subscript) -> None: if self._is_float_key(get_slice_expr(node)): self.add_violation(best_practices.FloatKeyViolation(node))