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

Change subject: [flake8] simplify code
......................................................................

[flake8] simplify code

Change-Id: I51687ba6f163dca05ecbb515d136fa4c82af88d1
---
M pywikibot/_wbtypes.py
M pywikibot/flow.py
M pywikibot/site/_extensions.py
M tests/page_tests.py
4 files changed, 25 insertions(+), 16 deletions(-)

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




diff --git a/pywikibot/_wbtypes.py b/pywikibot/_wbtypes.py
index 1daf583..bbda021 100644
--- a/pywikibot/_wbtypes.py
+++ b/pywikibot/_wbtypes.py
@@ -464,15 +464,15 @@
         if self.month > 1:
             elapsed_seconds += self._month_offset[self.month] * 24 * 60 * 60
             # The greogrian calendar
-            if self.calendarmodel == 'http://www.wikidata.org/entity/Q1985727':
-                if (self.year % 400 == 0
-                        or (self.year % 4 == 0 and self.year % 100 != 0)
-                        and self.month > 2):
-                    elapsed_seconds += 24 * 60 * 60  # Leap year
+            if (self.calendarmodel == 'http://www.wikidata.org/entity/Q1985727'
+                and (self.year % 400 == 0
+                     or (self.year % 4 == 0 and self.year % 100 != 0)
+                     and self.month > 2)):
+                elapsed_seconds += 24 * 60 * 60  # Leap year
             # The julian calendar
-            if self.calendarmodel == 'http://www.wikidata.org/entity/Q1985786':
-                if self.year % 4 == 0 and self.month > 2:
-                    elapsed_seconds += 24 * 60 * 60
+            if (self.calendarmodel == 'http://www.wikidata.org/entity/Q1985786'
+                    and self.year % 4 == 0 and self.month > 2):
+                elapsed_seconds += 24 * 60 * 60
         if self.day > 1:
             # Days start at 1, not 0.
             elapsed_seconds += (self.day - 1) * 24 * 60 * 60
diff --git a/pywikibot/flow.py b/pywikibot/flow.py
index b6b71b7..96401c3 100644
--- a/pywikibot/flow.py
+++ b/pywikibot/flow.py
@@ -1,6 +1,6 @@
 """Objects representing Flow entities, like boards, topics, and posts."""
 #
-# (C) Pywikibot team, 2015-2023
+# (C) Pywikibot team, 2015-2024
 #
 # Distributed under the terms of the MIT license.
 #
@@ -325,7 +325,7 @@

         :return: summary or None
         """
-        if 'summary' in self.root._current_revision.keys():
+        if 'summary' in self.root._current_revision:
             return self.root._current_revision['summary']['revision'][
                 'content']['content']
         return None
diff --git a/pywikibot/site/_extensions.py b/pywikibot/site/_extensions.py
index bfa343f..aadf1b4 100644
--- a/pywikibot/site/_extensions.py
+++ b/pywikibot/site/_extensions.py
@@ -1,6 +1,6 @@
 """Objects representing API interface to MediaWiki site extenstions."""
 #
-# (C) Pywikibot team, 2008-2022
+# (C) Pywikibot team, 2008-2024
 #
 # Distributed under the terms of the MIT license.
 #
@@ -584,7 +584,7 @@
         params = {'action': 'flow', 'page': page, 'token': token,
                   'submodule': 'edit-topic-summary', 'etssummary': summary,
                   'etsformat': 'wikitext'}
-        if 'summary' in page.root._current_revision.keys():
+        if 'summary' in page.root._current_revision:
             params['etsprev_revision'] = page.root._current_revision[
                 'summary']['revision']['revisionId']
         req = self._request(parameters=params, use_get=False)
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 075c79e..242be28 100755
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 """Tests for the page module."""
 #
-# (C) Pywikibot team, 2008-2023
+# (C) Pywikibot team, 2008-2024
 #
 # Distributed under the terms of the MIT license.
 #
@@ -270,9 +270,9 @@
             'File:Example',  # no file extension
             'File:Example #3.jpg',  # file extension in section
         ):
-            with self.subTest(title=title):
-                with self.assertRaises(ValueError):
-                    pywikibot.FilePage(site, title)
+            with self.subTest(title=title), \
+                 self.assertRaises(ValueError):
+                pywikibot.FilePage(site, title)

     def testImageAndDataRepository(self):
         """Test image_repository and data_repository page attributes."""

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/991971
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: I51687ba6f163dca05ecbb515d136fa4c82af88d1
Gerrit-Change-Number: 991971
Gerrit-PatchSet: 3
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