Page MenuHomePhabricator

API to use Warning system
Closed, DeclinedPublic

Description

Currently the API module uses a custom warning system, and some parts of the codebase dont correctly handle multiple warnings:

http://git.wikimedia.org/blob/pywikibot%2Fcore.git/9ca1b85c367b381947426c2615f4ab246e497518/pywikibot%2Fsite.py#L4167

The API should be migrated to using the Python core warning system

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


Version: core-(2.0)
Severity: normal
See Also:
T72970: use DeprecationWarning system

Details

Reference
bz71738

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:50 AM
bzimport set Reference to bz71738.
bzimport added a subscriber: Unknown Object (????).

This seems similar to T72970 which has been resolved with I95000736f3fc9ccb80fe32106fb6516abc62cdd6. But the rest of the API (all calls to pywikibot(.bot).warning) are still not going via warnings.warn.

Hmm. Changeset https://gerrit.wikimedia.org/r/#/c/168574 is about this. The outstanding problem is how to integrate the upload script warning management (905b276c7e0ec284872ab66c06b2fabdad397795)

Why are we replacing only warn() when we could also replace the log(), critical(), error() functions using the inbuilt logging module ?
https://docs.python.org/2/library/logging.html

Xqt triaged this task as High priority.May 28 2017, 11:56 AM
Xqt claimed this task.
Xqt subscribed.

The proposal is not really sufficient. The warning module is for avoidable issues and the client application should be modified to eliminate the warning whereas logging.warning should be used if there is nothing the client application can do about the situation, but the event should still be noted. The API warnings are out of our scope I guess

Xqt changed the task status from Resolved to Declined.Oct 4 2020, 12:10 PM

See comment above. Refer https://docs.python.org/3.10/howto/logging.html for further informations.