Skip to content

Some callback annotations violate LSP #179

@wRAR

Description

@wRAR

scrapy.Spider.parse has a Response type hint for the response argument, and custom callbacks may also have hints for response and for some kwargs, and then in subclasses the callback with the same name can have different hints for the same arguments. In the simplest case it's just response: DummyResponse.

All of these violate the Liskov substitution principle and mypy will produce errors for the overridden callbacks. This should already happen when the base class is user-defined and will also happen for any parse() with e.g. response: DummyResponse after Scrapy with py.typed is released.

I don't currently have any suggestions for resolving this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions