jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1101145?usp=email )

Change subject: IMPR: simplify site_detect.py
......................................................................

IMPR: simplify site_detect.py

decrease nested flow statements in MWSite.__init__()

Change-Id: I339e0c2a8c67505bc07ab7fe9a986607564189a4
---
M pywikibot/site_detect.py
1 file changed, 12 insertions(+), 11 deletions(-)

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




diff --git a/pywikibot/site_detect.py b/pywikibot/site_detect.py
index 728f9e2..8613f88 100644
--- a/pywikibot/site_detect.py
+++ b/pywikibot/site_detect.py
@@ -41,10 +41,11 @@
     def __init__(self, fromurl, **kwargs) -> None:
         """Initializer.

-        :raises pywikibot.exceptions.ServerError: a server error occurred
-            while loading the site
+        :raises pywikibot.exceptions.ServerError: a server error
+            occurred while loading the site
         :raises Timeout: a timeout occurred while loading the site
-        :raises RuntimeError: Version not found or version less than 1.27
+        :raises RuntimeError: Version not found or version less than
+            1.27
         """
         fromurl = removesuffix(fromurl, '$1')

@@ -85,17 +86,17 @@
             raise RuntimeError(f'Unsupported version: {self.version}')

         if not self.articlepath:
-            if self.private_wiki:
-                if self.api != self.fromurl and self.private_wiki:
-                    self.articlepath = self.fromurl.rsplit('/', 1)[0] + '/$1'
-                else:
-                    raise RuntimeError(
-                        'Unable to determine articlepath because the wiki is '
-                        'private. Use the Main Page URL instead of the API.')
-            else:
+            if not self.private_wiki:
                 raise RuntimeError(
                     f'Unable to determine articlepath: {self.fromurl}')

+            if self.api == self.fromurl:
+                raise RuntimeError(
+                    'Unable to determine articlepath because the wiki is '
+                    'private. Use the Main Page URL instead of the API.')
+
+            self.articlepath = self.fromurl.rsplit('/', 1)[0] + '/$1'
+
     def __repr__(self) -> str:
         return f'{type(self).__name__}("{self.fromurl}")'


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

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I339e0c2a8c67505bc07ab7fe9a986607564189a4
Gerrit-Change-Number: 1101145
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org
To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org

Reply via email to