delete
statement in a local scope PTC-W0043del
statement in a local scope188 ):
189 locals()[method] = _simple_escaping_wrapper(method)
190
191 del method192
193 def partition(self, sep: str) -> t.Tuple["Markup", "Markup", "Markup"]:
194 l, s, r = super().partition(self.escape(sep))
Passing a local variable to a del
statement results in that variable being removed from the local namespace.
When exiting a function all local variables are deleted, so it is unnecessary to explicitly delete variables in such cases.
It is recommended to remove this del
statement.
Not preferred:
def my_func():
task = do_some_task()
evaluate_task(task)
del task # This is unnecessary.
Preferred:
def my_func():
task = do_some_task()
evaluate_task(task)