Skip to content

Type checker reports error when using the Use class in a boolean operator #322

Open
@PleasantFuban

Description

@PleasantFuban

Here is a minimal example:

schema = Schema({
    'party': And(str, Use(str.lower), lambda s: s in ('alice', 'bob'))
})

This code works fine. However, the type checker reports an error saying that a Use instance cannot be used as an argument of And(). This is true in both VS Code (which uses pyright by default) and PyCharm.

I'm using similar validation rules in many places. As a result, my code is full of # type: ignores because otherwise I will have to disable type checking completely.

Is it possible to solve this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions