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

Change subject: [BUG] exturlusage: protocol can't be a list
......................................................................

[BUG] exturlusage: protocol can't be a list

Change-Id: I66d697546268560953a888e6a5e88a9554f0adc6
---
M pywikibot/site/_generators.py
M tests/site_generators_tests.py
2 files changed, 9 insertions(+), 22 deletions(-)

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




diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index debd456..fe44f35 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -1317,7 +1317,7 @@
     def exturlusage(
         self,
         url: str | None = None,
-        protocol: str | list[str] | None = None,
+        protocol: str | None = None,
         namespaces: NamespaceArgType = None,
         total: int | None = None,
         content: bool = False,
@@ -1331,11 +1331,9 @@
             of the hostname
         :param namespaces: list of namespace numbers to fetch contribs from
         :param total: Maximum number of pages to retrieve in total
-        :param protocol: list of protocols to search for, http and https by
-                default. Full list shown on Special:LinkSearch wikipage
+        :param protocol: protocol to search for, http and https by default.
+                Full list shown on Special:LinkSearch wikipage
         """
-        if isinstance(protocol, str):
-            protocol = [protocol]
         if url is not None:
             found_protocol, _, url = url.rpartition('://')

@@ -1345,18 +1343,12 @@
                 url = None

             if found_protocol:
-                if protocol:
-                    if len(protocol) > 1:
-                        raise ValueError(
-                            'More than one protocol was specified and a  '
-                            'protocol was found in searched url'
-                        )
-                    if protocol[0] != found_protocol:
-                        raise ValueError(
-                            f'Protocol {protocol!r} was specified, but '
-                            f'{found_protocol!r} was found in searched url'
-                        )
-                protocol = [found_protocol]
+                if protocol and protocol != found_protocol:
+                    raise ValueError(
+                        f'Protocol {protocol!r} was specified, but '
+                        f'{found_protocol!r} was found in searched url'
+                    )
+                protocol = found_protocol

         return self._generator(api.PageGenerator, type_arg='exturlusage',
                                geuquery=url, geuprotocol=protocol,
diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py
index 7bf8655..8ee081f 100755
--- a/tests/site_generators_tests.py
+++ b/tests/site_generators_tests.py
@@ -596,11 +596,6 @@
             mysite.exturlusage('https://www.google.com', protocol='http')
         with self.assertRaises(ValueError):
             mysite.exturlusage('http://www.google.com', protocol='https')
-        with self.assertRaises(ValueError):
-            mysite.exturlusage(
-                'https://www.google.com',
-                protocol=['http', 'https'],
-            )

     def test_protectedpages_create(self) -> None:
         """Test that protectedpages returns protected page titles."""

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

Reply via email to