jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/630638 )

Change subject: [cleanup] Show a FutureWarning for methods which are deprecated 
for 5 years
......................................................................

[cleanup] Show a FutureWarning for methods which are deprecated for 5 years

Bug: T106121
Change-Id: I9678cb0866b07c683fde3a9a925856fbfbc0f126
---
M pywikibot/__init__.py
M pywikibot/bot.py
M pywikibot/comms/http.py
M pywikibot/data/api.py
M pywikibot/date.py
M pywikibot/editor.py
M pywikibot/families/wikimediachapter_family.py
M pywikibot/family.py
M pywikibot/i18n.py
M pywikibot/logentries.py
M pywikibot/page/__init__.py
M pywikibot/site/__init__.py
M pywikibot/textlib.py
M pywikibot/tools/__init__.py
14 files changed, 71 insertions(+), 47 deletions(-)

Approvals:
  JJMC89: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index df21568..7045a95 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1252,7 +1252,8 @@


 # alias for backwards-compability
-getSite = redirect_func(Site, old_name='getSite', since='20150924')
+getSite = redirect_func(Site, old_name='getSite', since='20150924',
+                        future_warning=True)


 # These imports depend on Wb* classes above.
@@ -1408,12 +1409,12 @@
 wrapper = _ModuleDeprecationWrapper(__name__)
 wrapper._add_deprecated_attr(
     'cookie_jar', replacement_name='pywikibot.comms.http.cookie_jar',
-    since='20150921')
+    since='20150921', future_warning=True)
 wrapper._add_deprecated_attr(
     'QuitKeyboardInterrupt', _QuitKeyboardInterrupt,
     warning_message='pywikibot.QuitKeyboardInterrupt is deprecated; '
                     'use pywikibot.bot.QuitKeyboardInterrupt instead.',
-    since='20150619')
+    since='20150619', future_warning=True)
 wrapper._add_deprecated_attr(
     'MediaWikiVersion', _MediaWikiVersion,
     warning_message='pywikibot.MediaWikiVersion is deprecated; '
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 619f6a6..da21a7f 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -863,7 +863,7 @@
     return non_global_args


-@deprecated('handle_args', since='20150409')
+@deprecated('handle_args', since='20150409', future_warning=True)
 def handleArgs(*args):
     """DEPRECATED. Use handle_args()."""
     return handle_args(args)
@@ -1545,7 +1545,8 @@
         super().__init__(**kwargs)

     @property
-    @deprecated("the page's site property", since='20150615')
+    @deprecated("the page's site property", since='20150615',
+                future_warning=True)
     def site(self):
         """
         Return the site if it's set and ValueError otherwise.
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 74e5f98..ffd1c48 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -242,7 +242,7 @@
         # +1 because of @deprecate_arg
         issue_deprecation_warning(
             'Invoking http.request without argument site', 'http.fetch()', 3,
-            since='20150814')
+            warning_class=FutureWarning, since='20150814')
         r = fetch(uri, method, params, body, headers, **kwargs)
         return r.text

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index be9f6b2..e7be358 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -708,7 +708,7 @@
         return {'{}+{}'.format(prefix, mod) for mod in modules}

     @property
-    @deprecated('prefix_map', since='20150715')
+    @deprecated('prefix_map', since='20150715', future_warning=True)
     def prefixes(self):
         """
         Mapping of module to its prefix for all modules with a prefix.
@@ -752,7 +752,7 @@
         return {mod: self[mod][attribute]
                 for mod in modules if attribute in self[mod]}

-    @deprecated('attributes', since='20150715')
+    @deprecated('attributes', since='20150715', future_warning=True)
     def module_attribute_map(self, attribute: str,
                              modules: Optional[set] = None):
         """
@@ -775,7 +775,7 @@
                 for mod in modules if self[mod][attribute]}

     @property
-    @deprecated('parameter()', since='20150905')
+    @deprecated('parameter()', since='20150905', future_warning=True)
     def query_modules_with_limits(self):
         """Set of all query modules which have limits."""
         if not self._with_limits:
diff --git a/pywikibot/date.py b/pywikibot/date.py
index 9d0bf50..360099e 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -177,7 +177,7 @@
     return v[0]


-@deprecated(since='20151014')
+@deprecated(since='20151014', future_warning=True)
 def encNoConv(i):
     """Return i."""
     return i
@@ -2164,7 +2164,7 @@
         formatLimits[dayMnthFmts[monthId]] = _format_limit_dom(30)


-@deprecated('calendar.monthrange', since='20150707')
+@deprecated('calendar.monthrange', since='20150707', future_warning=True)
 def getNumberOfDaysInMonth(month):
     """
     Return the maximum number of days in a given month, 1 being January, etc.
diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index b505a56..a95401d 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -71,8 +71,7 @@
         return ' '.join("'{0}'".format(part) if ' ' in part else part
                         for part in command)

-    @deprecated('_command (should not be used from the outside)',
-                since='20150111', future_warning=True)
+    @deprecated(since='20150111', future_warning=True)
     def command(self, tempFilename, text, jumpIndex=None):
         """Return editor selected in user-config.py."""
         return TextEditor._concat(self._command(tempFilename, text, jumpIndex))
diff --git a/pywikibot/families/wikimediachapter_family.py 
b/pywikibot/families/wikimediachapter_family.py
index ed59ba5..063f771 100644
--- a/pywikibot/families/wikimediachapter_family.py
+++ b/pywikibot/families/wikimediachapter_family.py
@@ -28,7 +28,7 @@
     ]

     @classproperty
-    @deprecated(since='20150621')
+    @deprecated(since='20150621', future_warning=True)
     def countries(cls):
         """Deprecated."""
         return cls.codes
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 58e2c92..e980d95 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -663,14 +663,17 @@
             issue_deprecation_warning('nocapitalize',
                                       "APISite.siteinfo['case'] or "
                                       "Namespace.case == 'case-sensitive'",
+                                      warning_class=FutureWarning,
                                       since='20150214')
         elif name == 'known_families':
             issue_deprecation_warning('known_families',
                                       'APISite.interwiki(prefix)',
+                                      warning_class=FutureWarning,
                                       since='20150503')
         elif name == 'shared_data_repository':
             issue_deprecation_warning('shared_data_repository',
                                       'APISite.data_repository()',
+                                      warning_class=FutureWarning,
                                       since='20151023')
         return super().__getattribute__(name)

@@ -731,14 +734,15 @@
         return cls
 
     @classproperty
-    @deprecated('Family.codes or APISite.validLanguageLinks', since='20151014')
+    @deprecated('Family.codes or APISite.validLanguageLinks', since='20151014',
+                future_warning=True)
     def iwkeys(cls):
         """DEPRECATED: List of (interwiki_forward's) family codes."""
         if cls.interwiki_forward:
             return list(pywikibot.Family(cls.interwiki_forward).langs.keys())
         return list(cls.langs.keys())

-    @deprecated('APISite.interwiki', since='20151014')
+    @deprecated('APISite.interwiki', since='20151014', future_warning=True)
     def get_known_families(self, site):
         """DEPRECATED: Return dict of inter-family interwiki links."""
         return self.known_families
@@ -912,7 +916,7 @@
         """Return path to api.php."""
         return '%s/api.php' % self.scriptpath(code)

-    @deprecated('APISite.article_path', since='20150905')
+    @deprecated('APISite.article_path', since='20150905', future_warning=True)
     def nicepath(self, code):
         """DEPRECATED: Return nice path prefix, e.g. '/wiki/'."""
         return '/wiki/'
@@ -930,7 +934,8 @@
         """Return the path to title using index.php with redirects disabled."""
         return '%s?title=%s&redirect=no' % (self.path(code), title)

-    @deprecated('APISite.nice_get_address(title)', since='20150628')
+    @deprecated('APISite.nice_get_address(title)', since='20150628',
+                future_warning=True)
     def nice_get_address(self, code, title):
         """DEPRECATED: Return the nice path to title using index.php."""
         return '%s%s' % (self.nicepath(code), title)
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 99fe2e3..d748422 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -775,7 +775,7 @@
         return trans


-@deprecated('twtranslate', since='20151009')
+@deprecated('twtranslate', since='20151009', future_warning=True)
 @deprecated_args(code='source')
 def twntranslate(source, twtitle, parameters=None):
     """DEPRECATED: Get translated string for the key."""
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 61a31a3..b9a5d41 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -99,7 +99,7 @@
         else:  # try old mw style preceding mw 1.19
             return self[self._expected_type]

-    @deprecated('page()', since='20150617')
+    @deprecated('page()', since='20150617', future_warning=True)
     def title(self):
         """
         DEPRECATED: Alias for page().
@@ -285,7 +285,7 @@

     _expected_type = 'move'

-    @deprecated('target_ns.id', since='20150518')
+    @deprecated('target_ns.id', since='20150518', future_warning=True)
     def new_ns(self):
         """Return namespace id of target page."""
         return self.target_ns.id
@@ -298,7 +298,7 @@
                                     if 'target_ns' in self._params
                                     else self._params['new_ns']]

-    @deprecated('target_page', since='20150518')
+    @deprecated('target_page', since='20150518', future_warning=True)
     def new_title(self):
         """Return page object of the new title."""
         return self.target_page
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index f819ab0..d22780a 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -584,12 +584,12 @@
         del self.latest_revision_id
         self._revid = value

-    @deprecated('latest_revision_id', since='20150727')
+    @deprecated('latest_revision_id', since='20150727', future_warning=True)
     def latestRevision(self):
         """Return the current revision id for this page."""
         return self.latest_revision_id

-    @deprecated('latest_revision_id', since='20150407')
+    @deprecated('latest_revision_id', since='20150407', future_warning=True)
     def pageAPInfo(self):
         """Return the current revision id for this page."""
         if self.isRedirectPage():
@@ -738,7 +738,7 @@

     @property
     @deprecated('latest_revision.parent_id (0 instead of -1 when no parent)',
-                since='20150609')
+                since='20150609', future_warning=True)
     def previous_revision_id(self) -> int:
         """
         Return the revision id for the previous revision of this Page.
@@ -748,7 +748,7 @@
         return self.latest_revision.parent_id or -1

     @deprecated('latest_revision.parent_id (0 instead of -1 when no parent)',
-                since='20150609')
+                since='20150609', future_warning=True)
     def previousRevision(self) -> int:
         """
         Return the revision id for the previous revision.
@@ -833,7 +833,7 @@
             return Category(Link(self._catredirect, self.site))
         raise pywikibot.IsNotRedirectPage(self)

-    @deprecated(since='20151207')
+    @deprecated(since='20151207', future_warning=True)
     def isEmpty(self) -> bool:
         """
         Return True if the page text has less than 4 characters.
@@ -1638,7 +1638,7 @@
         """
         return self.site.getredirtarget(self)

-    @deprecated('moved_target()', since='20150524')
+    @deprecated('moved_target()', since='20150524', future_warning=True)
     def getMovedTarget(self):
         """
         Return a Page object for the target this Page was moved to.
@@ -1748,7 +1748,8 @@
         return sum(cnt[user.username] if isinstance(user, User) else cnt[user]
                    for user in contributors)

-    @deprecated('contributors() or revisions()', since='20150206')
+    @deprecated('contributors() or revisions()', since='20150206',
+                future_warning=True)
     @deprecated_args(limit='total')
     def getLatestEditors(self, total=1) -> list:
         """
@@ -2130,7 +2131,7 @@
                                  'required.' % self.title(as_link=True))
         return False

-    @deprecated('Page.is_flow_page()', since='20150128')
+    @deprecated('Page.is_flow_page()', since='20150128', future_warning=True)
     def isFlowPage(self):
         """DEPRECATED: use self.is_flow_page instead."""
         return self.is_flow_page()
@@ -2171,7 +2172,7 @@

 # ####### DEPRECATED METHODS ########

-    @deprecated('Page.protection()', since='20150725')
+    @deprecated('Page.protection()', since='20150725', future_warning=True)
     def getRestrictions(self):
         """DEPRECATED. Use self.protection() instead."""
         restrictions = self.protection()
@@ -4108,6 +4109,7 @@
         if name == 'lastrevid':
             issue_deprecation_warning(
                 'WikibasePage.lastrevid', 'latest_revision_id',
+                warning_class=FutureWarning,
                 since='20150607')
             name = '_revid'
         return super().__getattribute__(name)
@@ -4117,6 +4119,7 @@
         if attr == 'lastrevid':
             issue_deprecation_warning(
                 'WikibasePage.lastrevid', 'latest_revision_id',
+                warning_class=FutureWarning,
                 since='20150607')
             attr = '_revid'
         return super().__setattr__(attr, value)
@@ -4126,6 +4129,7 @@
         if attr == 'lastrevid':
             issue_deprecation_warning(
                 'WikibasePage.lastrevid', 'latest_revision_id',
+                warning_class=FutureWarning,
                 since='20150607')
             attr = '_revid'
         return super().__delattr__(attr)
diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py
index dfcd1b3..72b0dac 100644
--- a/pywikibot/site/__init__.py
+++ b/pywikibot/site/__init__.py
@@ -386,7 +386,8 @@
         return False

     @classmethod
-    @deprecated('NamespacesDict.lookup_name', since='20150703')
+    @deprecated('NamespacesDict.lookup_name', since='20150703',
+                future_warning=True)
     def lookup_name(cls, name, namespaces=None):
         """
         Find the Namespace for a name.
@@ -404,7 +405,8 @@
         return NamespacesDict._lookup_name(name, namespaces)

     @staticmethod
-    @deprecated('NamespacesDict.resolve', since='20150703')
+    @deprecated('NamespacesDict.resolve', since='20150703',
+                future_warning=True)
     def resolve(identifiers, namespaces=None):
         """
         Resolve namespace identifiers to obtain Namespace objects.
@@ -943,7 +945,8 @@
         """
         return self._interwikimap[prefix].local

-    @deprecated('APISite.namespaces.lookup_name', since='20150703')
+    @deprecated('APISite.namespaces.lookup_name', since='20150703',
+                future_warning=True)
     def ns_index(self, namespace):
         """
         Return the Namespace for a given namespace name.
@@ -955,7 +958,8 @@
         """
         return self.namespaces.lookup_name(namespace)

-    @deprecated('APISite.namespaces.lookup_name', since='20150703')
+    @deprecated('APISite.namespaces.lookup_name', since='20150703',
+                future_warning=True)
     def getNamespaceIndex(self, namespace):
         """DEPRECATED: Return the Namespace for a given namespace name."""
         return self.namespaces.lookup_name(namespace)
@@ -1152,7 +1156,8 @@
         """Return local name for the Category namespace."""
         return self.namespace(14)

-    @deprecated('list(namespaces.CATEGORY)', since='20150829')
+    @deprecated('list(namespaces.CATEGORY)', since='20150829',
+                future_warning=True)
     def category_namespaces(self):
         """Return names for the Category namespace."""
         return list(self.namespace(14, all=True))
@@ -1174,7 +1179,8 @@

     # deprecated methods for backwards-compatibility

-    @deprecated('pywikibot.data.api.encode_url', since='20151211')
+    @deprecated('pywikibot.data.api.encode_url', since='20151211',
+                future_warning=True)
     def urlEncode(self, query):
         """DEPRECATED."""
         return api.encode_url(query)
@@ -1978,7 +1984,7 @@
         else:
             return [word]

-    @deprecated('expand_text', since='20150831')
+    @deprecated('expand_text', since='20150831', future_warning=True)
     def resolvemagicwords(self, wikitext):
         """
         Replace the {{ns:xx}} marks in a wikitext with the namespace names.
@@ -2073,7 +2079,8 @@
         """Site information dict."""
         return self._siteinfo

-    @deprecated('siteinfo or Namespace instance', since='20150830')
+    @deprecated('siteinfo or Namespace instance', since='20150830',
+                future_warning=True)
     def case(self):
         """Return this site's capitalization rule."""
         # This is the global setting via $wgCapitalLinks, it is used whenever
@@ -2084,7 +2091,7 @@
         """Return this site's internal id."""
         return self.siteinfo['wikiid']

-    @deprecated('APISite.lang', since='20150629')
+    @deprecated('APISite.lang', since='20150629', future_warning=True)
     def language(self):
         """Return the code for the language of this Site."""
         return self.lang
@@ -2468,7 +2475,8 @@
         return (pageitem['imageinfo']
                 if history else pageitem['imageinfo'][0])

-    @deprecated('Check the content model instead', since='20150128')
+    @deprecated('Check the content model instead', since='20150128',
+                future_warning=True)
     def loadflowinfo(self, page):
         """
         Load Flow-related information about a given page.
@@ -2938,7 +2946,7 @@

         return user_tokens

-    @deprecated("the 'tokens' property", since='20150218')
+    @deprecated("the 'tokens' property", since='20150218', future_warning=True)
     @remove_last_args(['sysop'])
     def getToken(self, getalways=True, getagain=False):
         """DEPRECATED: Get edit token."""
@@ -2955,7 +2963,7 @@
             del self.tokens._tokens[self.user()][token]
         return self.tokens[token]

-    @deprecated("the 'tokens' property", since='20150218')
+    @deprecated("the 'tokens' property", since='20150218', future_warning=True)
     @remove_last_args(['sysop'])
     def getPatrolToken(self):
         """DEPRECATED: Get patrol token."""
@@ -5618,7 +5626,8 @@
                                       '"report_success" is True or None',
                                       '"report_success=False" or define '
                                       '"ignore_warnings" as callable/iterable',
-                                      3, since='20150823')
+                                      3, warning_class=FutureWarning,
+                                      since='20150823')
         if isinstance(ignore_warnings, Iterable):
             ignored_warnings = ignore_warnings

@@ -6914,6 +6923,7 @@
         """Check that claim.on_item is set and matches baserevid if used."""
         if not claim.on_item:
             issue_deprecation_warning('claim without on_item set', depth=3,
+                                      warning_class=FutureWarning,
                                       since='20160309')
             if not baserevid:
                 warn('Neither claim.on_item nor baserevid provided',
@@ -6965,7 +6975,8 @@
                 else:  # urls
                     instead = None
                 issue_deprecation_warning('DataSite.{0}()'.format(attr),
-                                          instead, since='20151022')
+                                          instead, warning_class=FutureWarning,
+                                          since='20151022')
                 if props == 'urls':
                     props = 'sitelinks/urls'
                 method = self._get_propertyitem
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 972c290..2fe5fe2 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -313,6 +313,7 @@
                     issue_deprecation_warning(
                         'site=None',
                         "a valid site for '{}' regex".format(exc),
+                        warning_class=FutureWarning,
                         since='20151006')
                     site = pywikibot.Site()

@@ -2034,7 +2035,7 @@
         """Deprecated comment_pattern instance variable."""
         return self._comment_pat

-    @deprecated('module function', since='20151118')
+    @deprecated('module function', since='20151118', future_warning=True)
     def findmarker(self, text: str, base: str = '@@', delta: str = '@'):
         """Find a string which is not part of text."""
         return findmarker(text, base, delta)
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 9293b20..10bf6bc 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -892,7 +892,9 @@
         """Do nothing and just return itself."""
         if hasattr(self, '_own_desc'):
             issue_deprecation_warning('Calling {}'.format(self._own_desc),
-                                      'it directly', since='20150515')
+                                      'it directly',
+                                      warning_class=FutureWarning,
+                                      since='20150515')
         return self



--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/630638
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I9678cb0866b07c683fde3a9a925856fbfbc0f126
Gerrit-Change-Number: 630638
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Isaacandy <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to