Skip to content

pickle.Pickler.reducer_override: Positional parameter count mismatch; base method has 1, but override has 2 #13446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
eachimei opened this issue Jan 30, 2025 · 1 comment · May be fixed by #13545
Labels
stubs: false positive Type checkers report false errors

Comments

@eachimei
Copy link

CPython docs explain about Pickler.reduce_override:

https://docs.python.org/3/library/pickle.html#custom-reduction-for-types-functions-and-other-objects

it is possible to subclass from the Pickler class and implement a reducer_override() method.

And a code example is provided:

...
import pickle
...
class MyPickler(pickle.Pickler):
    def reducer_override(self, obj):
        """Custom reducer for MyClass."""
        ...

However, my code that does that now fails with pyright 1.1.393:

error: Method "reducer_override" overrides class "Pickler" in an incompatible manner
    Positional parameter count mismatch; base method has 1, but override has 2 (reportIncompatibleMethodOverride)

I think it's because of this definition in typeshed:

reducer_override: Callable[[Any], Any]

@eachimei
Copy link
Author

eachimei commented Feb 2, 2025

FYI @erictraut

@srittau srittau added the stubs: false positive Type checkers report false errors label Feb 26, 2025
srittau added a commit to srittau/typeshed that referenced this issue Feb 26, 2025
@srittau srittau linked a pull request Feb 26, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants