Skip to content

Support type annotations via typing.Generic #122

Open
@honorabel

Description

@honorabel

It would be great if both the range value type and mapped value type could be annotated with type annotations, e.g.:

@dataclass
class Foo:
  a: int
  b: str

tree = IntervalTree[int, Foo]()

tree[2, 5] = Foo(123, 'test')

# linter should raise type error:
tree[1.4, 2.3] = Foo(123, 'test')

# linter should raise type error:
tree[2, 5] = 'invalid value type'

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