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

Change subject: tests: update type hints and use a constant for several 
identical messages
......................................................................

tests: update type hints and use a constant for several identical messages

Change-Id: Iad6de389babccc28964c29106d3e67a695d0a197
---
M tests/aspects.py
1 file changed, 14 insertions(+), 7 deletions(-)

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




diff --git a/tests/aspects.py b/tests/aspects.py
index 27799fd..0bca615 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -57,6 +57,9 @@


 OSWIN32 = (sys.platform == 'win32')
+SIZED_ERROR = 'seq argument is not a Sized class containing __len__'
+
+
 pywikibot.bot.set_interface('buffer')


@@ -90,7 +93,7 @@
     def assertIsEmpty(self, seq, msg=None):
         """Check that the sequence is empty."""
         self.assertIsInstance(
-            seq, Sized, 'seq argument is not a Sized class containing __len__')
+            seq, Sized, SIZED_ERROR)
         if seq:
             msg = self._formatMessage(msg, f'{safe_repr(seq)} is not empty')
             self.fail(msg)
@@ -98,7 +101,7 @@
     def assertIsNotEmpty(self, seq, msg=None):
         """Check that the sequence is not empty."""
         self.assertIsInstance(
-            seq, Sized, 'seq argument is not a Sized class containing __len__')
+            seq, Sized, SIZED_ERROR)
         if not seq:
             msg = self._formatMessage(msg, f'{safe_repr(seq)} is empty')
             self.fail(msg)
@@ -107,7 +110,7 @@
         """Verify that a sequence seq has the length of other."""
         # the other parameter may be given as a sequence too
         self.assertIsInstance(
-            seq, Sized, 'seq argument is not a Sized class containing __len__')
+            seq, Sized, SIZED_ERROR)
         first_len = len(seq)
         try:
             second_len = len(other)
@@ -132,9 +135,11 @@
         self.assertIn(page.namespace(), namespaces,
                       f'{page} not in namespace {namespaces!r}')

-    def _get_gen_pages(self,
-                       gen: Iterable[pywikibot.Page],
-                       site: pywikibot.site.APISite = None) -> None:
+    def _get_gen_pages(
+        self,
+        gen: Iterable[pywikibot.Page],
+        site: pywikibot.site.APISite | None = None
+    ) -> list[pywikibot.Page]:
         """Get pages from gen, asserting they are Page from site.

         .. versionchanged:: 9.3
@@ -154,7 +159,9 @@

         return gen_pages

-    def _get_gen_titles(self, gen, site=None) -> list[str]:
+    def _get_gen_titles(self,
+                        gen: list[pywikibot.Page],
+                        site=None) -> list[str]:
         """Return a list of page titles of given iterable."""
         return [page.title() for page in self._get_gen_pages(gen, site)]


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

Reply via email to