Skip to content

Error converting Sequence to tuple #2607

@jakevdp

Description

@jakevdp

Describe the Bug

The following code fails to typecheck with pyrefly v0.54.0:

from typing import Sequence

def f(x: Sequence[int]) -> tuple[int, ...]:
    if isinstance(x, tuple):
        return x
    return tuple(x)
$ uv run pyrefly check tmp.py 
ERROR Returned type `tuple[*Sequence[int]]` is not assignable to declared return type `tuple[int, ...]` [bad-return]
 --> tmp.py:5:16
  |
5 |         return x
  |                ^
  |
 INFO 1 error

Sandbox Link

sandbox link

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions