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

feat: add ConstructorEager type #1091

Merged
merged 16 commits into from
Oct 17, 2024

Conversation

lucianosrp
Copy link
Member

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

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

Checklist

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

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

@github-actions github-actions bot added the enhancement New feature or request label Sep 28, 2024
@lucianosrp
Copy link
Member Author

lucianosrp commented Sep 28, 2024

Getting some issues with type checking.

tests/expr_and_series/sort_test.py:30: error: Item "NativeFrame" of "NativeFrame | DataFrame[Any] | DataFrameLike" has no attribute "equals"  [union-attr]
tests/expr_and_series/sort_test.py:30: error: Item "DataFrame[Any]" of "NativeFrame | DataFrame[Any] | DataFrameLike" has no attribute "equals"  [union-attr]
tests/expr_and_series/sort_test.py:30: error: Item "DataFrameLike" of "NativeFrame | DataFrame[Any] | DataFrameLike" has no attribute "equals"  [union-attr]

Should I also add equals to the NativeFrame protocol?

EDIT:
I ended up removing the typehint on sort_test.py:30 as I don't think any dataframe would have the equals method (?)

@lucianosrp lucianosrp marked this pull request as ready for review October 6, 2024 09:29
@lucianosrp
Copy link
Member Author

lucianosrp commented Oct 6, 2024

Not sure how to handle the mypy failure on interchange_to_arrow_test and interchange_schema_test this time.
@FBruzzesi , perhaps you could have a look? I am sure I am missing something very obvious haha

Solved

Copy link
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 @lucianosrp ! just a comment, but I think the rest is fine

Comment on lines 31 to 36
def __getitem__(self, *args: Any, **kwargs: Any) -> Any: ...

class DataFrameLike(Protocol):
def __dataframe__(self, *args: Any, **kwargs: Any) -> Any: ...
def __getitem__(self, *args: Any, **kwargs: Any) -> Any: ...

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should be modifying this

@MarcoGorelli
Copy link
Member

Getting some issues with type checking.

tests/expr_and_series/sort_test.py:30: error: Item "NativeFrame" of "NativeFrame | DataFrame[Any] | DataFrameLike" has no attribute "equals"  [union-attr]
tests/expr_and_series/sort_test.py:30: error: Item "DataFrame[Any]" of "NativeFrame | DataFrame[Any] | DataFrameLike" has no attribute "equals"  [union-attr]
tests/expr_and_series/sort_test.py:30: error: Item "DataFrameLike" of "NativeFrame | DataFrame[Any] | DataFrameLike" has no attribute "equals"  [union-attr]

Should I also add equals to the NativeFrame protocol?

EDIT: I ended up removing the typehint on sort_test.py:30 as I don't think any dataframe would have the equals method (?)

I think you can rewrite the test as follows:

    result = (
        df.select(
            "a",
            nw.col("b").sort(descending=descending, nulls_last=nulls_last),
        )
    )
    compare_dicts(result, expected)

@lucianosrp
Copy link
Member Author

This has been stale for a while. I'll try to make it right this weekend πŸ”₯

Copy link
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.

awesome, thanks @lucianosrp !

@lucianosrp
Copy link
Member Author

Many thanks @MarcoGorelli ! I will merge it nowπŸŽ‰

@MarcoGorelli MarcoGorelli merged commit 82b1d6e into narwhals-dev:main Oct 17, 2024
25 checks passed
@lucianosrp lucianosrp deleted the add-constructor-eager-type branch October 17, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: type constructor_eager as ConstructorEager instead of Constructor
2 participants