delete
statement in a local scope PTC-W0043del
statement in a local scope1881 loc = None
1882 with suppress(KeyError):
1883 tmpl, loc = moved_links[page.site.code]
1884 del tmpl1885 if loc is not None and loc in page.title():
1886 pywikibot.info(
1887 f'Skipping: {page.title()} is a templates subpage')
del
statement in a local scope 525 elif arg == 'ignorefile':
526 ignore_page_gen = pagegenerators.TextIOPageGenerator(value)
527 self.ignore.update(ignore_page_gen)
528 del ignore_page_gen 529 elif arg == 'showpage':
530 self.showtextlink += self.showtextlinkadd
531 elif arg == 'graph':
del
statement in a local scope 516 elif arg == 'skipfile':
517 skip_page_gen = pagegenerators.TextIOPageGenerator(value)
518 self.skip.update(skip_page_gen)
519 del skip_page_gen 520 elif arg == 'neverlink':
521 self.neverlink += value.split(',')
522 elif arg == 'ignore':
del
statement in a local scope 811 start = m.start()
812 # Since this point the m variable shouldn't be used as it may not
813 # contain all contents
814 del m 815
816 try:
817 link = pywikibot.Link.create_separated(
del
statement in a local scope 846 page = pywikibot.Page(self.site, 'Pywikibot nobots test')
847 page.text = content
848 self.assertFalse(page.botMayEdit())
849 del page 850
851
852class TestPageHistory(DefaultSiteTestCase):
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)