Skip to content

Narwhals: from_native() return type incompatible with attribute assignment #1739

@akmalsoliev

Description

@akmalsoliev

Describe the Bug

Hey folks,
Based on the discussion on the call this is the MRE:

import narwhals as nw
class Validate:
    def __init__(self, frame: IntoFrame) -> None:
        # ensuring that the Frame is of Narwhals type
        self.frame = nw.from_native(frame)

Error:

ERROR `LazyFrame[NativeDataFrame | NativeLazyFrame | _NativeIbis]` is not assignable to attribute `frame` with type `NativeDataFrame | NativeLazyFrame | _NativeIbis` [bad-assignment]
  --> validoopsie/validate.py:43:26
   |
43 |             self.frame = nw.from_native(frame)
   |                          ^^^^^^^^^^^^^^^^^^^^^
   |
 INFO 1 error (2 ignored)

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions