Skip to content

Allow keyword arguments on codecs encode/decode callables - #16688

Closed
hrithiksaini99 wants to merge 1 commit into
python:mainfrom
hrithiksaini99:fix-codecs-codecinfo-keyword-args
Closed

hrithiksaini99 wants to merge 1 commit into
python:mainfrom
hrithiksaini99:fix-codecs-codecinfo-keyword-args

Conversation

@hrithiksaini99

Copy link
Copy Markdown
Contributor

Fixes the false positive reported in #16441: codecs.CodecInfo.decode / encode returned by codecs.lookup were typed via positional-only Protocol callables, so calling with errors="..." keyword was rejected even though the runtime bound methods accept it.

import codecs

codec = codecs.lookup("utf-8")
codec.decode(b"potato", errors="replace")  # was: Unexpected keyword argument "errors"
codec.encode("hello", errors="replace")    # was: Unexpected keyword argument "errors"

The errors parameter is now positional-or-keyword, matching the runtime signature.

Agent: DeepSeek V4.1 Flash (OpenCode).

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau

srittau commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Dupe with your own PR ...

@srittau srittau closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants