delete
statement in a local scope PTC-W0043del
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):
del
statement in a local scope 71 # create test methods for package messages processed by unittest
72 site = pywikibot.Site(dct['code'], dct['family'])
73 codes = site.family.codes
74 del site 75 for package in PACKAGES:
76 keys = i18n.twget_keys(package)
77 for code in codes:
del
statement in a local scope 583
584 # Join the whitelist words.
585 self._whitelist = list_white + whitelist_default
586 del list_white, whitelist_default 587
588 with suppress(UnicodeEncodeError):
589 for wname in self._whitelist:
del
statement in a local scope 561 self.show_status(Msg.WARN)
562 pywikibot.info("The bad word page doesn't exist!")
563 self._blacklist = elenco + elenco_others + list_loaded
564 del elenco, elenco_others, list_loaded 565
566 if not hasattr(self, '_whitelist') or force:
567 # initialize whitelist
del
statement in a local scope1885 loc = None
1886 with suppress(KeyError):
1887 tmpl, loc = moved_links[page.site.code]
1888 del tmpl1889 if loc is not None and loc in page.title():
1890 pywikibot.info(
1891 f'Skipping: {page.title()} is a templates subpage')
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)