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

Change subject: doc: Clarify articlepath property docstring and replace assert 
with exception
......................................................................

doc: Clarify articlepath property docstring and replace assert with exception

Change-Id: I95ae3889474c794422e29b0441fffe1c373c5fb2
---
M pywikibot/site/_apisite.py
1 file changed, 13 insertions(+), 3 deletions(-)

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




diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 5098e40..9ee6fb4 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -828,13 +828,23 @@

     @property
     def articlepath(self) -> str:
-        """Get the nice article path with ``{}``placeholder.
+        """Return article path with a ``{}`` placeholder.
+
+        Replaces the ``$1`` placeholder from MediaWiki with a
+        Python-compatible ``{}``.

         .. versionadded:: 7.0
+
+        .. versionchanged:: 10.3
+           raises ValueError instead of AttributeError if "$1"
+           placeholder is missing.
+
+        :raises ValueError: missing "$1" placeholder
         """
         path = self.siteinfo['general']['articlepath']
-        # Assert $1 placeholder is present
-        assert '$1' in path, 'articlepath must contain "$1" placeholder'
+        if '$1' not in path:
+            raise ValueError(
+                f'Invalid article path "{path}": missing "$1" placeholder')
         return path.replace('$1', '{}')

     @cached

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