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

Change subject: [IMPR] replace some format strings with f-strings
......................................................................

[IMPR] replace some format strings with f-strings

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

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




diff --git a/pywikibot/site_detect.py b/pywikibot/site_detect.py
index c79983f..3d61a3f 100644
--- a/pywikibot/site_detect.py
+++ b/pywikibot/site_detect.py
@@ -93,12 +93,11 @@
                         'Unable to determine articlepath because the wiki is '
                         'private. Use the Main Page URL instead of the API.')
             else:
-                raise RuntimeError('Unable to determine articlepath: '
-                                   '{}'.format(self.fromurl))
+                raise RuntimeError(
+                    f'Unable to determine articlepath: {self.fromurl}')

     def __repr__(self) -> str:
-        return '{}("{}")'.format(
-            self.__class__.__name__, self.fromurl)
+        return f'{type(self).__name__}("{self.fromurl}")'

     @property
     def langs(self):
@@ -108,9 +107,11 @@
             + '?action=query&meta=siteinfo&siprop=interwikimap'
               '&sifilteriw=local&format=json')
         iw = response.json()
-        if 'error' in iw:
-            raise RuntimeError('{} - {}'.format(iw['error']['code'],
-                                                iw['error']['info']))
+
+        error = iw.get('error')
+        if error:
+            raise RuntimeError(f"{error['code']} - {error['info']}")
+
         return [wiki for wiki in iw['query']['interwikimap']
                 if 'language' in wiki]

@@ -151,9 +152,8 @@
                 'Private wiki detected. Login is required.\n'
                 'Please enter your username?')
             # Setup a dummy family so that we can create a site object
-            fam = pywikibot.family.AutoFamily(
-                'temporary_family',
-                self.api[:-8])
+            fam = pywikibot.family.AutoFamily('temporary_family',
+                                              self.server + self.scriptpath)
             site = pywikibot.Site(fam.code, fam, username)
             site.version = lambda: str(self.version)
             # Now the site object is able to login
@@ -259,8 +259,8 @@
                     self._parsed_url, new_parsed_url)

         self._parsed_url = new_parsed_url
-        self.server = '{}://{}'.format(
-            self._parsed_url.scheme, self._parsed_url.netloc)
+        self.server = '{url.scheme}://{url.netloc}'.format(
+            url=self._parsed_url)
         self.scriptpath = self._parsed_url.path

     def handle_starttag(self, tag, attrs) -> None:

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/908982
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: I708c0ca1eda2c9a37d1f291e63b7075a74b7e842
Gerrit-Change-Number: 908982
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to