Skip to content

Petitions.get() overrides HttpMethods.get() with an incompatible signature #19

Description

@aaronelliotross

What's happening

actionkit/petitions.py:57-58:

def get(self, id):
    return super().get(f"petitionpage/{id}/")

overrides the base class's:

def get(self, resource_uri=None, *args, **params):

The override is not compatible with the base contract:

  • No query-param (**params) support.
  • Hardcodes "petitionpage/{id}/" rather than using self.resource_name (currently the same value, "petitionpage", but that's coincidental, not delegated).
  • Calling it the way the base class documents its contract — Petitions.get(resource_uri=...) — raises TypeError, since the override has no resource_uri parameter.

This is a Liskov-substitution break: code written generically against HttpMethods.get's signature cannot safely call Petitions.get.

Suggested fix direction

Rename to something like get_by_id(id) (there's already a HttpMethods.get_by_id convention used elsewhere) instead of overriding get, or bring the signature in line with the base class (get(self, resource_uri=None, *args, **params)) and derive the id-based path from resource_uri when it looks like a bare id.

Test coverage

Pinned by tests/test_petitions.py::test_get_by_id_hardcodes_petitionpage_path and tests/test_petitions.py::test_get_with_resource_uri_kwarg_breaks_the_override (the latter documents the break, not a fix).

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions