jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/889240 )
Change subject: fix B028 by adding stacklevel=2 ......................................................................
fix B028 by adding stacklevel=2
Change-Id: I121816f67ecddd8d37a488dafd0c580e9f85ff6e --- M pywikibot/family.py 1 file changed, 28 insertions(+), 10 deletions(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py index 22b83fc..639a273 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -320,22 +320,31 @@ raise UnknownFamilyError(f'Family {fam} does not exist') cls = mod.Family.instance if cls.name != fam: - warnings.warn('Family name {} does not match family module name {}' - .format(cls.name, fam), FamilyMaintenanceWarning) + warnings.warn( + 'Family name {} does not match family module name {}' + .format(cls.name, fam), + FamilyMaintenanceWarning, + stacklevel=2, + ) # Family 'name' and the 'langs' codes must be ascii letters and digits, # and codes must be lower-case due to the Site loading algorithm; # codes can accept also underscore/dash. if not all(x in NAME_CHARACTERS for x in cls.name): - warnings.warn('Name of family {} must be ASCII letters ' - 'and digits [a-zA-Z0-9]' - .format(cls.name), FamilyMaintenanceWarning) + warnings.warn( + 'Name of family {} must be ASCII letters and digits ' + '[a-zA-Z0-9]'.format(cls.name), + FamilyMaintenanceWarning, + stacklevel=2, + ) for code in cls.langs.keys(): if not all(x in CODE_CHARACTERS for x in code): - warnings.warn('Family {} code {} must be ASCII lowercase ' - 'letters and digits [a-z0-9] or ' - 'underscore/dash [_-]' - .format(cls.name, code), - FamilyMaintenanceWarning) + warnings.warn( + 'Family {} code {} must be ASCII lowercase letters and ' + ' digits [a-z0-9] or underscore/dash [_-]' + .format(cls.name, code), + FamilyMaintenanceWarning, + stacklevel=2, + ) Family._families[fam] = cls return cls