Skip to content

Contracts #5

@senko

Description

@senko

Should we support contracts?

It would be straightforward to support contracts by supporting custom callables in type signatures. For example:

@params(a=int, b=lambda b: b != 0)
def div(a, b):
    return a / b

However, I find that syntax clunky (for contracts), compared to something like:

@contract
def div(a, b):
    return a / b

@div.requires
def div(a, b):
    assert isinstance(a, int)
    assert b != 0

But this being typedecorator, not a full-blown contracts library, I'm hesitant to grow it in that direction (unless there's popular demand).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions