jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] config2: clarify UserWarning error messages

In Ie50078ae3315ba8ba70946b889a31e403c998dd7 a user-config var was removed
without depreciation.
This patch aims to clarify the different messages that are not very understandable,
as T166682 shows, making it clear that user-config.py file need to be edited.

Bug: T166682
Change-Id: I893f9817fb0838749bf062e72cd82438ec6ad0fb
---
M pywikibot/config2.py
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index fb85461..9a655f1 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -1046,10 +1046,10 @@

def __init__(self, name, actual_type, allowed_types):
super(_DifferentTypeError, self).__init__(
- 'Configuration variable "{0}" is defined as "{1.__name__}" but '
- 'expected "{2}".'.format(
- name, actual_type,
- '", "'.join(t.__name__ for t in allowed_types)))
+ 'Configuration variable "{0}" is defined as "{1.__name__}" in '
+ 'your user-config.py but expected "{2}".'
+ .format(name, actual_type, '", "'.join(t.__name__
+ for t in allowed_types)))


def _assert_default_type(name, value, default_value):
@@ -1086,8 +1086,10 @@
else:
user_config[name] = value
elif not name.startswith('_') and name not in skipped:
- warn('Configuration variable {0} is defined but unknown. '
- 'Misspelled?'.format(name), UserWarning)
+ warn('Configuration variable "{0}" is defined in your '
+ 'user-config.py but unknown. It can be a misspelled one or a '
+ 'variable that is no longer supported.'
+ .format(name), UserWarning)


_check_user_config_types(_uc, _glv, _imports)
@@ -1112,9 +1114,9 @@
globals()[_key] = _uc[_key]

if _key in _deprecated_variables:
- warn("'%s' is no longer a supported configuration variable.\n"
- "Please inform the maintainers if you depend on it." % _key,
- _ConfigurationDeprecationWarning)
+ warn('"{0}" present in our user-config.py is no longer a supported '
+ 'configuration variable. Please inform the maintainers if you '
+ 'depend on it.'.format(_key), _ConfigurationDeprecationWarning)

# If we cannot auto-detect the console encoding (e.g. when piping data)
# assume utf-8. On Linux, this will typically be correct; on windows,

To view, visit change 440909. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I893f9817fb0838749bf062e72cd82438ec6ad0fb
Gerrit-Change-Number: 440909
Gerrit-PatchSet: 1
Gerrit-Owner: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot