Skip to content

fix: fix type __get_item__#1958

Merged
MarcoGorelli merged 3 commits intonarwhals-dev:mainfrom
EdAbati:type-get-item
Feb 7, 2025
Merged

fix: fix type __get_item__#1958
MarcoGorelli merged 3 commits intonarwhals-dev:mainfrom
EdAbati:type-get-item

Conversation

@EdAbati
Copy link
Copy Markdown
Collaborator

@EdAbati EdAbati commented Feb 7, 2025

What type of PR is this? (check all applicable)

  • 💾 Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 🔧 Optimization
  • 📝 Documentation
  • ✅ Test
  • 🐳 Other

Related issues

Related to the mypy discussion on discord. I found few errors that should be better tackled in separate PRs :)

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

not sure if changing this should be allowed, but in theory we are just expanding the allowed types (adding np.array that is suppoerted anyway)
🤔

Copy link
Copy Markdown
Member

@dangotbanned dangotbanned Feb 7, 2025

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup, totally allowed 😄 adding types should still be backwards-compatible

@EdAbati EdAbati marked this pull request as ready for review February 7, 2025 07:39
@dangotbanned
Copy link
Copy Markdown
Member

dangotbanned commented Feb 7, 2025

@EdAbati I think the issue you're running into is that np.ndarray is not a Sequence

import numpy as np
from collections.abc import Sequence

>>> isinstance(np.ndarray((2,2)), Sequence)
False

Edit

I might have spoke too soon, I'm getting the same failures on (https://github.com/narwhals-dev/narwhals/actions/runs/13200872617/job/36852325981?pr=1955)

Copy link
Copy Markdown
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks @EdAbati , and Dan for reviewing!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup, totally allowed 😄 adding types should still be backwards-compatible

@MarcoGorelli MarcoGorelli merged commit 20d52d7 into narwhals-dev:main Feb 7, 2025
23 of 24 checks passed
@EdAbati EdAbati mentioned this pull request Feb 7, 2025
10 tasks
@EdAbati EdAbati deleted the type-get-item branch February 8, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants