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

HasMetadata doesn't work in some subclasses #49

Open
wRAR opened this issue Jul 19, 2023 · 1 comment
Open

HasMetadata doesn't work in some subclasses #49

wRAR opened this issue Jul 19, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@wRAR
Copy link
Member

wRAR commented Jul 19, 2023

This fails:

def test_metadata_with_returns():
    class MyProduct(Product):
        pass

    class CustomProductPage(ProductPage, Returns[MyProduct]):
        pass

    url = ResponseUrl("https://example.com")
    html = b""
    page = CustomProductPage(response=HttpResponse(url=url, body=html))
    metadata = page.metadata
    @field
    def metadata(self) -> MetadataT:
>       value = self.metadata_cls()
E       TypeError: 'NoneType' object is not callable

zyte_common_items/pages.py:67: TypeError

zyte_common_items.pages._get_metadata_class in the case of this CustomProductPage cannot find any HasMetadata base and returns None.

@wRAR wRAR added the bug Something isn't working label Jul 19, 2023
@wRAR
Copy link
Member Author

wRAR commented Jul 19, 2023

AFAICS __orig_bases__ is not recursive, so _get_metadata_class needs to be recursive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant