Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support type annotations via typing.Generic #122

Open
honorabel opened this issue Jan 30, 2023 · 3 comments
Open

Support type annotations via typing.Generic #122

honorabel opened this issue Jan 30, 2023 · 3 comments

Comments

@honorabel
Copy link

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'
@Lubba-64
Copy link

Here are some experimental type stubs:
https://github.com/Lubba-64/intervaltree-stubs

@iainelder
Copy link

@Lubba-64 how do we use them?

@Lubba-64
Copy link

Lubba-64 commented Jan 5, 2024

I created these type stubs while in a clone of the original repo. I do not recall how or if I set it up for production, I ended up with a custom solution to replace this library anyways since my use case was different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants