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

Account for .loc[Scalar, list] in DataFrame #1109

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

carschandler
Copy link

As of now, the syntax:

df.loc[0, ["a", "b"]]

Yields the following typing error:

reportArgumentType: Argument of type "tuple[Literal[1], list[str]]" cannot be assigned to parameter "idx" of type "tuple[Scalar, slice]" in function "__getitem__"
  "tuple[Literal[1], list[str]]" is not assignable to "tuple[Scalar, slice]"
    Tuple entry 2 is incorrect type
      "list[str]" is not assignable to "slice"

I need help determining what the appropriate contents of the list should be (Hashable?) so I hope this can open discussion.

  • Closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added: Please use assert_type() to assert the type of any return value

As of now, the syntax:

```python
df.loc[0, ["a", "b"]]
```

Yields the following typing error:
```
reportArgumentType: Argument of type "tuple[Literal[1], list[str]]" cannot be assigned to parameter "idx" of type "tuple[Scalar, slice]" in function "__getitem__"
  "tuple[Literal[1], list[str]]" is not assignable to "tuple[Scalar, slice]"
    Tuple entry 2 is incorrect type
      "list[str]" is not assignable to "slice"
```

I need help determining what the appropriate contents of the `list` should be (`Hashable`?) so I hope this can open discussion.
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this in tests/test_frame.py ?

Make sure to use the check(assert_type( pattern

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

Successfully merging this pull request may close these issues.

2 participants