Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
The change LGTM. Maybe we can just deprecate the maxsplit parameter and add a new count, so we don't break existing code. But this sounds more like a bug, and I guess few users rely on this, so I'm not sure which way is better. BTW I read your article on HN about your Lean formalization of Python, which is very interesting! |
|
Thanks! I went with a plain rename because |
|
It was documented implicitly by saying it's compatible with |
…ead of removing it Keep accepting the old keyword name for a deprecation period instead of breaking callers that pass maxsplit= (typeshed spells the parameter maxsplit). Passing maxsplit= now emits a DeprecationWarning and is slated for removal in Python 3.18; passing both count and maxsplit raises TypeError. This mirrors the deprecation of the 'string' keyword parameter in hashlib (pythongh-134978), with a two-year period.
|
Typeshed spells the parameter |
Documentation build overview
8 files changed ·
|
collections.UserString.replace()called its third parametermaxsplit, soUserString('aa').replace('a', 'b', count=1)raisedTypeErroreven thoughstr.replace()has acceptedcountas a keyword since 3.13. This renames it tocountto matchstr.replace().The existing
test_count_keywordinLib/test/string_tests.pycalledreplaceonstrliterals, so it never ran againstUserString(orbytes/bytearray). It now goes throughcheckequal, which exercises every type that shares these tests.Compatibility: a caller passing
maxsplit=by keyword now getsTypeError. That name was never documented andstr.replace()never accepted it, and I found no callers in the stdlib.