Skip to content

Consider using descriptive type errors for invalid cast cases #5

@Martoon-00

Description

@Martoon-00

As far as I understand, currently, when I use e.g. intCast incorrectly, I will get Couldn't match type ‘'False’ with ‘'True’ error. It may be not immediately obvious that the conversion method is used incorrectly, and the types between which we convert are not mentioned here so understanding the cause of the failure may take a bit of extra time.

I propose using TypeError to provide better error messages. For instance, it is possible to define some CheckIntSubType wrapper over IsIntSubType that would report Cannot convert a to b error on failure, and then conversion methods can use these Check* constraints instead of ~ 'True.

I'm really happy that I finally found this library, and to me it looks like the most proper solution to the problem; hope it could be polished to final bits of perfection. 🙂

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