Page MenuHomePhabricator

use DeprecationWarning system
Closed, ResolvedPublic

Description

pywikibot includes a lot of deprecation methods and parameters to support old code. The deprecation messages are logged using the normal python logging system, but are not routed through warnings.DeprecationWarning, which allows command line control over whether they are displayed (and defaults to not being displayed)

https://docs.python.org/2/library/warnings.html#warnings.warn


Version: core-(2.0)
Severity: major
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=71738

Details

Reference
bz70970
Related Gerrit Patches:
pywikibot/core : masterUse warnings for deprecation

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:52 AM
bzimport set Reference to bz70970.
bzimport added a subscriber: Unknown Object (????).
jayvdb created this task.Sep 17 2014, 10:34 PM
jayvdb added a comment.Nov 9 2014, 8:05 PM

The deprecation notices are too noisy - users with custom scripts get scared when their screen is full of repetitive warnings.

For me, I prefer to see repetitive warnings which indicate that I should fix my script. Also, I strongly disagree that warning should not be displayed by default. The purpose of warning is to let users know explicitly. If something needs not to show to users, then switch to .debug instead (which will only show in verbose mode).

jayvdb moved this task from Backlog to Next release on the Pywikibot board.Nov 29 2014, 7:47 AM
gerritbot added a subscriber: gerritbot.

Change 187106 had a related patch set uploaded (by John Vandenberg):
Use warnings for deprecation

https://gerrit.wikimedia.org/r/187106

Patch-For-Review

The warnings system allows individuals to select how many warnings they want to see. we could add a config option to assist.

Or -verbose and config.verbose_output could enable this?

XZise added a subscriber: XZise.Jan 29 2015, 11:59 AM

Yeah it seems sensible that -verbose should enable this. Another problem is actually, that the logging levels are now don't make sense anymore. There is a WARNING level which is always shown and there are warnings which aren't shown by default.

There is a WARNING level which is always shown and there are warnings which aren't shown by default.

are you referring to the tools warnings shown on travis? I believe that is a separate problem relating to how some tests are run before 'bot' initialisation. There are ui_tests for warning, but they probably dont check that warnings are not shown if the logging subsystem is set at error level.

With regards to warnings.warn we should be setting the warnings filters to honour the config settings. The warnings regarding config are subclasses of UserWarning, which are shown by default. Currently, the warnings about config problems were using 'print' and thus were previously always shown (i.e. they were not warnings) . The warnings regarding arguments will likely change a bit when we move to argparse, so we should consider that in the implementation of warnings.

Change 187106 merged by jenkins-bot:
Use warnings for deprecation

https://gerrit.wikimedia.org/r/187106

jayvdb closed this task as Resolved.Jun 4 2015, 9:35 AM
jayvdb claimed this task.
Ricordisamoa set Security to None.
Ricordisamoa removed a project: Pywikibot-General.
Ricordisamoa edited subscribers, added: Ricordisamoa; removed: gerritbot.