Skip to content

Return type of service.models.Product.find_by* should be flask_sqlalchemy.query.QueryΒ #16

@jonoillar

Description

@jonoillar

Hello,

First of all thank you for setting up this lab πŸ”₯

I spotted one typo:

The return type of service.models.Product.find_by* methods is a flask_sqlalchemy.query.Query, and not a list as what is shown in the code in https://github.com/ibm-developer-skills-network/xgcyk-tdd-bdd-final-project-template/blob/main/service/models.py#L193

I.e. in line https://github.com/ibm-developer-skills-network/xgcyk-tdd-bdd-final-project-template/blob/main/service/models.py#L193 we see:

    def find_by_name(cls, name: str) -> list:
        """Returns all Products with the given name

        :param name: the name of the Products you want to match
        :type name: str

        :return: a collection of Products with that name
        :rtype: list

        """
        logger.info("Processing name query for %s ...", name)
        return cls.query.filter(cls.name == name)

However, actually the return type is flask_sqlalchemy.query.Query : the cls.query.filter functionsreturns a Query object

So I think this typo could be fixed, and furthermore could be spotted by the static linter

This typo is present in all of the find_by functions.

Lore: I discovered this typo when I was working on the lab, trying to get the length of the returned list with len was failing πŸ₯²

Thank you and have a nice day ! πŸ™‚

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