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

Change subject: [IMPR] remove some IDE warnings for site.py
......................................................................

[IMPR] remove some IDE warnings for site.py

Major change is to convert Site.redirectRegex() to
the property Site.redirect_regex, to avoid different signature
than base method's one.
Method has been deprecated with FutureWarning.

Change-Id: Icf7ea15683fa8f566acb7b28a7c37b3790bed1a2
---
M pywikibot/cosmetic_changes.py
M pywikibot/page/__init__.py
M pywikibot/site/__init__.py
M scripts/redirect.py
M tests/basesite_tests.py
5 files changed, 27 insertions(+), 18 deletions(-)

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



diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 6df193a..f6273ea 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -788,7 +788,7 @@
         if not self.template:
             exceptions = ['comment', 'math', 'nowiki', 'pre',
                           'syntaxhighlight', 'template', 'timeline',
-                          self.site.redirectRegex()]
+                          self.site.redirect_regex]
             text = textlib.replaceExcept(
                 text,
                 r'(?m)'
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index b4d259f..b2c38cd 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -2255,7 +2255,7 @@
             raise pywikibot.NoPage(self)
         if self.exists() and not self.isRedirectPage() and not force:
             raise pywikibot.IsNotRedirectPage(self)
-        redirect_regex = self.site.redirectRegex()
+        redirect_regex = self.site.redirect_regex
         if self.exists():
             old_text = self.get(get_redirect=True)
         else:
diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py
index e29b610..fe62cba 100644
--- a/pywikibot/site/__init__.py
+++ b/pywikibot/site/__init__.py
@@ -202,7 +202,8 @@
         gen.set_maximum_items(total)
         return gen

-    def _request_class(self, kwargs):
+    @staticmethod
+    def _request_class(kwargs):
         """
         Get the appropriate class.

@@ -333,7 +334,7 @@
         if login_manager.login(retry=True, autocreate=autocreate):
             self._username = login_manager.username
             del self.userinfo  # force reloading
-            self.userinfo  # load userinfo
+            assert self.userinfo['name'] == self.username()  # load userinfo
             self._loginstatus = _LoginStatus.AS_USER
         else:
             self._loginstatus = _LoginStatus.NOT_LOGGED_IN  # failure
@@ -517,7 +518,8 @@
             'articlepath must end with /$1'
         return self.siteinfo['general']['articlepath'][:-2]

-    def assert_valid_iter_params(self, msg_prefix, start, end, reverse,
+    @staticmethod
+    def assert_valid_iter_params(msg_prefix, start, end, reverse,
                                  is_ts=True):
         """Validate iterating API parameters.

@@ -836,7 +838,13 @@
         # return the magic word without the preceding '#' character
         return self.getmagicwords('redirect')[0].lstrip('#')

+    @deprecated('redirect_regex', since='20210103', future_warning=True)
     def redirectRegex(self):
+        """Return a compiled regular expression matching on redirect pages."""
+        return self.redirect_regex
+
+    @property
+    def redirect_regex(self):
         """Return a compiled regular expression matching on redirect pages.

         Group 1 in the regex match object will be the target title.
@@ -891,9 +899,10 @@
             except KeyError:
                 pywikibot.warning(
                     'Broken namespace alias "{0}" (id: {1}) on {2}'.format(
-                        item['*'], item['id'], self))
-            if item['*'] not in namespace:
-                namespace.aliases.append(item['*'])
+                        item['*'], ns, self))
+            else:
+                if item['*'] not in namespace:
+                    namespace.aliases.append(item['*'])

         return _namespaces

@@ -2227,7 +2236,7 @@

         By default, retrieves the last (current) revision of the page,
         unless any of the optional parameters revids, startid, endid,
-        starttime, endtime, rvdir, user, excludeuser, or limit are
+        starttime, endtime, rvdir, user, excludeuser, or total are
         specified. Unless noted below, all parameters not specified
         default to False.

@@ -2254,9 +2263,10 @@
         @keyword starttime: retrieve revisions starting at this Timestamp
         @keyword endtime: stop upon reaching this Timestamp
         @keyword rvdir: if false, retrieve newest revisions first (default);
-            if true, retrieve earliest first
+            if true, retrieve oldest first
         @keyword user: retrieve only revisions authored by this user
         @keyword excludeuser: retrieve all revisions not authored by this user
+        @keyword total: number of revisions to retrieve
         @raises ValueError: invalid startid/endid or starttime/endtime values
         @raises pywikibot.Error: revids belonging to a different page
         """
@@ -4334,13 +4344,12 @@
         raise RuntimeError(
             'Unexpected success of upload action without parameters.')

-    def stash_info(self, file_key, props=False):
+    def stash_info(self, file_key, props=None):
         """Get the stash info for a given file key.

         @see: U{https://www.mediawiki.org/wiki/API:Stashimageinfo}
         """
-        if not props:
-            props = False
+        props = props or False
         req = self._simple_request(
             action='query', prop='stashimageinfo', siifilekey=file_key,
             siiprop=props)
@@ -5584,8 +5593,8 @@

         @see: U{https://www.mediawiki.org/wiki/API:Watchlistraw}

-        @param force_reload: Reload watchlist
-        @type force_reload: bool
+        @param force: Reload watchlist
+        @type force: bool
         @param total: if not None, limit the generator to yielding this many
             items in total
         @type total: int
@@ -6282,7 +6291,7 @@
         @param claim: A Claim object to remove the sources from
         @type claim: pywikibot.Claim
         @param sources: A list of Claim objects that are sources
-        @type sources: pywikibot.Claim
+        @type sources: list
         @param bot: Whether to mark the edit as a bot edit
         @type bot: bool
         @param summary: Edit summary
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 9b07caf..21584c5 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -138,7 +138,7 @@
         redict = {}
         # open xml dump and read page titles out of it
         dump = xmlreader.XmlDump(xmlFilename)
-        redirR = self.site.redirectRegex()
+        redirR = self.site.redirect_regex
         readPagesCount = 0
         pageTitles = set()
         for entry in dump.parse():
diff --git a/tests/basesite_tests.py b/tests/basesite_tests.py
index 392789c..96a8395 100644
--- a/tests/basesite_tests.py
+++ b/tests/basesite_tests.py
@@ -107,7 +107,7 @@
             self.assertEqual(foo, '[[Foo]]')

         self.assertFalse(mysite.isInterwikiLink('foo'))
-        self.assertIsInstance(mysite.redirectRegex().pattern, str)
+        self.assertIsInstance(mysite.redirect_regex.pattern, str)
         self.assertIsInstance(mysite.category_on_one_line(), bool)
         self.assertTrue(mysite.sametitle('Template:Test', 'Template:Test'))
         self.assertTrue(mysite.sametitle('Template: Test', 'Template:   Test'))

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/653977
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: Icf7ea15683fa8f566acb7b28a7c37b3790bed1a2
Gerrit-Change-Number: 653977
Gerrit-PatchSet: 6
Gerrit-Owner: Mpaa <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Xqt <[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