Skip to content
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

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

Open
eachimei opened this issue Jan 30, 2025 · 0 comments

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]

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

No branches or pull requests

1 participant