286 """
287 return self.binop_table[operator](left, right)
288
289 def call_unop(self, context: Context, operator: str, arg: t.Any) -> t.Any:290 """For intercepted unary operator calls (:meth:`intercepted_unops`)
291 this function is executed instead of the builtin operator. This can
292 be used to fine tune the behavior of certain operators.
276 )
277
278 def call_binop(
279 self, context: Context, operator: str, left: t.Any, right: t.Any280 ) -> t.Any:
281 """For intercepted binary operator calls (:meth:`intercepted_binops`)
282 this function is executed instead of the builtin operator. This can
255 self.binop_table = self.default_binop_table.copy()
256 self.unop_table = self.default_unop_table.copy()
257
258 def is_safe_attribute(self, obj: t.Any, attr: str, value: t.Any) -> bool:259 """The sandboxed environment will call this method to check if the
260 attribute of an object is safe to access. Per default all attributes
261 starting with an underscore are considered private as well as the
76 self.write(finalize.src)
77
78 def _output_child_post(
79 self, node: nodes.Expr, frame: Frame, finalize: CodeGenerator._FinalizeInfo 80 ) -> None:
81 if finalize.src is not None:
82 self.write(")")
70 return finalize.const(const) # type: ignore
71
72 def _output_child_pre(
73 self, node: nodes.Expr, frame: Frame, finalize: CodeGenerator._FinalizeInfo 74 ) -> None:
75 if finalize.src is not None:
76 self.write(finalize.src)
An unused argument can lead to confusions. It should be removed. If this variable is necessary, name the variable _
or start the name with unused
or _unused
.
def square(x, y=1):
return x * x
class MySubClass(MyClass):
def __init__(self, number):
self.value = 42 # argument `number` remains unused
def square(x):
return x * x
class MySubClass(MyClass):
def __init__(self, _):
self.value = 42