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

The to_tuple type decorators don't correctly handle generics for item types. #152

Open
pipermerriam opened this issue Apr 17, 2019 · 1 comment
Labels

Comments

@pipermerriam
Copy link
Member

What was wrong?

When using to_tuple on a function which operates on a generic type, type safety is not preserved.

TVal = TypeVar('TVal')

@to_tuple
def typing_to_tuple_generic(values: Sequence[TVal]) -> Iterable[TVal]:
    yield from values

v_tuple_generic = typing_to_tuple_generic([1, 2, 3])
reveal_type(v_tuple_generic)  # error: Revealed type is 'builtins.tuple[TVal`-1]'

How can it be fixed?

???

@pipermerriam
Copy link
Member Author

Not clear yet but this might be fixable using https://mypy.readthedocs.io/en/latest/extending_mypy.html#current-list-of-plugin-hooks

@reedsa reedsa added the p3 label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants