Skip to content

Serializer.load_payload overrides in subclasses have incompatible signatures #74

Closed
@ambv

Description

@ambv

Mypy recently introduced stricter checks for function signature compatibility (python/mypy#2521). Since itsdangerous is included in the typeshed library with typing stubs, it found an issue with the signatures of load_payload. Consider:

class Serializer:
  def load_payload(self, payload, serializer=None): ...

vs.

class JSONWebSignatureSerializer(Serializer):
  def load_payload(self, payload, return_header=False): ...

vs.

class URLSafeSerializerMixin(object):
  def load_payload(self, payload): ...

class URLSafeSerializer(URLSafeSerializerMixin, Serializer): ...
class TimedSerializer(Serializer): ...
class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer): ...

Basically, it's invalid to replace load_payload() accepting an optional kwarg with an implementation that doesn't.

Activity

davidism

davidism commented on Dec 23, 2016

@davidism
Member

PyCharm has complained about it for a while too. If you have a fix in mind, a patch would be great, otherwise I'll investigate.

added a commit that references this issue on Dec 23, 2016
19f68e4
ambv

ambv commented on Dec 23, 2016

@ambv
ContributorAuthor

Alright, PR ready.

added a commit that references this issue on Jan 6, 2017
b00d8fd
added this to the 1.0.0 milestone on Sep 28, 2018
locked as resolved and limited conversation to collaborators on Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Serializer.load_payload overrides in subclasses have incompatible signatures · Issue #74 · pallets/itsdangerous