Skip to content

Remove Indexable and use Sequence #52

@acampove

Description

@acampove

Hi,

I am having problems using propagate with lists and the source of the issue seems to be the Indexable class used for typehinting. For instance:

from jacobi._typing import Indexable

def foo(x: Indexable[float]) -> float:
    return x[0]

my_list: list[float] = [1.0, 2.0, 3.0]

foo(my_list)

shows me:

Argument of type "list[float]" cannot be assigned to parameter "x" of type "Indexable[float]" in function "foo"    "list[float]" is not assignable to "Indexable[float]"

and it seems that the class needs to implement len. In any case, there seems to be two ways around:

  1. Use Sequence from typing.
  2. Use a Protocol class with __getitem__ and len.

So I would just remove this class and use either 1 or 2.

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