jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/868132 )
Change subject: [IMPR] ignore original exception in BaseSite.__getattr__() ......................................................................
[IMPR] ignore original exception in BaseSite.__getattr__()
- ignore original exception usually from Family class when raising AttributeError in BaseSite.__getattr__() - also refactor exception message to use f-strings
Change-Id: I119fca320debdaa437c5acb5b61260b5223042c1 --- M pywikibot/site/_basesite.py 1 file changed, 15 insertions(+), 2 deletions(-)
Approvals: RoySmith: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site/_basesite.py b/pywikibot/site/_basesite.py index 80dacc7..7142d99 100644 --- a/pywikibot/site/_basesite.py +++ b/pywikibot/site/_basesite.py @@ -197,8 +197,8 @@ f.__doc__ = method.__doc__ return f except AttributeError: - raise AttributeError("{} instance has no attribute '{}'" - .format(self.__class__.__name__, attr)) + raise AttributeError(f'{type(self).__name__} instance has no ' + f'attribute {attr!r}') from None
def __str__(self) -> str: """Return string representing this Site's name and code."""