jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/680030 )
Change subject: [cleanup] Deprecate DotReadableDict ......................................................................
[cleanup] Deprecate DotReadableDict
DotReadableDict only defines itself as "Parent class of Revision() and FileInfo()" rather than providing anything useful. Revision no longer uses it, and DotReadableDict is a pretty trivial class so merging what it has into FileInfo.
Change-Id: I96eb5476e12c2afe8cceeb97419ffef5426ad3ab --- M pywikibot/page/__init__.py M pywikibot/tools/__init__.py 2 files changed, 14 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index a5aa643..2a6ba98 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -58,7 +58,6 @@ deprecated, deprecate_arg, deprecated_args, - DotReadableDict, first_upper, redirect_func, remove_last_args, @@ -4873,7 +4872,7 @@ }
-class FileInfo(DotReadableDict): +class FileInfo:
""" A structure holding imageinfo of latest rev. of FilePage. @@ -4895,6 +4894,14 @@ self.__dict__.update(file_revision) self.timestamp = pywikibot.Timestamp.fromISOformat(self.timestamp)
+ def __getitem__(self, key): + """Give access to class values by key.""" + return getattr(self, key) + + def __repr__(self): + """Return a more complete string representation.""" + return repr(self.__dict__) + def __eq__(self, other): """Test if two File_info objects are equal.""" return self.__dict__ == other.__dict__ diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py index f891c09..ac1ce9b 100644 --- a/pywikibot/tools/__init__.py +++ b/pywikibot/tools/__init__.py @@ -1900,3 +1900,8 @@ option_msg += '\n' + ' ' * indent option_msg += option_line return '{} ({}):'.format(message, option_msg) + + +wrapper = ModuleDeprecationWrapper(__name__) +wrapper._add_deprecated_attr('DotReadableDict', replacement_name='', + since='20210416', future_warning=True)