Skip to content

Index.difference should allow for None values in the "other" list #17

Closed
@svetlin-mladenov

Description

@svetlin-mladenov

Currently the type annotation for Index.difference is

def difference(self, other: Union[List[T1], Index]) -> Index: ...

None values are disallowed for the other argument if it is a list. As a result of that the following code, which runs perfectly fine, will give an error when mypy is used to check it:

from pandas.core.indexes.api import Index

index = Index(["a", "b", "c"])
index.difference(["a", None])

I think the function type should be changed to:

def difference(self, other: Union[List[Optional[T1]], Index]) -> Index: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions