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

Change subject: Use explicit prefix and suffix removal for known delimiters
......................................................................

Use explicit prefix and suffix removal for known delimiters

Use removesuffix() for the wrapper's normalized .py filename and
removeprefix() for the WbTime ISO year sign and splitext() extension dot.
These inputs already have at most one delimiter to remove, so their
normal processing retains the same results while making intent explicit.

Change-Id: Ib0b47e2785d8c401364d13afd8b01636a1d13733
---
M pywikibot/_wbtypes.py
M pywikibot/scripts/wrapper.py
M pywikibot/specialbots/_upload.py
3 files changed, 3 insertions(+), 3 deletions(-)

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




diff --git a/pywikibot/_wbtypes.py b/pywikibot/_wbtypes.py
index 945d377..ec882a7 100644
--- a/pywikibot/_wbtypes.py
+++ b/pywikibot/_wbtypes.py
@@ -908,7 +908,7 @@
         if self.year <= 0:
             raise ValueError('You cannot turn BC dates into a Timestamp')
         ts = Timestamp.fromISOformat(
-            self.toTimestr(force_iso=True).lstrip('+'))
+            self.toTimestr(force_iso=True).removeprefix('+'))
         if timezone_aware:
             ts = ts.replace(tzinfo=datetime.timezone(
                 datetime.timedelta(minutes=self.timezone)))
diff --git a/pywikibot/scripts/wrapper.py b/pywikibot/scripts/wrapper.py
index b409f1d..b150364 100755
--- a/pywikibot/scripts/wrapper.py
+++ b/pywikibot/scripts/wrapper.py
@@ -361,7 +361,7 @@
                 scripts[name] = script_name

     # remove .py for better matching
-    filename = filename[:-3]
+    filename = filename.removesuffix('.py')
     similar_scripts = get_close_matches(filename, scripts,
                                         config.pwb_close_matches,
                                         config.pwb_cut_off)
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index 1bc679f..39320a5 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -313,7 +313,7 @@
                     return None

             first_check = False
-            ext = os.path.splitext(filename)[1].lower().strip('.')
+            ext = os.path.splitext(filename)[1].lower().removeprefix('.')
             # are any chars in forbidden also in filename?
             invalid = set(forbidden) & set(filename)
             if invalid:

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

Reply via email to