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: make dependencies available under narwhals.stable.v1 for type checkers #1426

Closed
MarcoGorelli opened this issue Nov 22, 2024 · 7 comments · Fixed by #1430
Closed

feat: make dependencies available under narwhals.stable.v1 for type checkers #1426

MarcoGorelli opened this issue Nov 22, 2024 · 7 comments · Fixed by #1430
Labels
enhancement New feature or request good first issue Good for newcomers, but anyone is welcome to submit a pull request! help wanted Extra attention is needed

Comments

@MarcoGorelli
Copy link
Member

Currently

from narwhals.stable.v1.dependencies import is_pandas_like_dataframe

raises, but

from narwhals.stable.v1 import dependencies

passes

@MarcoGorelli MarcoGorelli added help wanted Extra attention is needed enhancement New feature or request labels Nov 22, 2024
@dangotbanned
Copy link

I've tried a few variants of import statements but not had any luck.

I think adding an __all__ would do the trick though, maybe one of the idoms from https://microsoft.github.io/pyright/#/typed-libraries?id=library-interface

Although making both mypy and pyright happy is more of a task

https://github.com/vega/altair/blob/c41e29e0bfa9e34d942635e574b2accfd9f2de0d/tools/generate_schema_wrapper.py#L1103-L1139

@MarcoGorelli
Copy link
Member Author

thanks for taking a look at that - i think we have it:

"dependencies",

we may just need to make a dependencies.py file in which we do the import, that'd probably be the simplest thing

@MarcoGorelli MarcoGorelli added the good first issue Good for newcomers, but anyone is welcome to submit a pull request! label Nov 22, 2024
@dangotbanned
Copy link

thanks for taking a look at that - i think we have it:

"dependencies",

we may just need to make a dependencies.py file in which we do the import, that'd probably be the simplest thing

Apologies if I've misunderstood your comment

I meant adding an __all__ here

if TYPE_CHECKING:
from types import ModuleType
from typing_extensions import Self
from narwhals.dtypes import DType
from narwhals.functions import ArrowStreamExportable
from narwhals.typing import IntoExpr
from narwhals.typing import IntoSeries
T = TypeVar("T")

@MarcoGorelli
Copy link
Member Author

sorry i may have misunderstood myself - don't we have it at the bottom of the file?

__all__ = [
"Array",
"Boolean",
"Categorical",
"DataFrame",
"Date",
"Datetime",
"Duration",
"Enum",
"Expr",
"Field",
"Float32",
"Float64",
"Int16",
"Int32",
"Int64",
"Int8",
"LazyFrame",
"List",
"Object",
"Schema",
"Series",
"String",
"Struct",
"UInt16",
"UInt32",
"UInt64",
"UInt8",
"Unknown",
"all",
"all_horizontal",
"any_horizontal",
"col",
"concat",
"concat_str",
"dependencies",
"exceptions",
"from_arrow",
"from_dict",
"from_native",
"generate_temporary_column_name",
"get_level",
"get_native_namespace",
"is_ordered_categorical",
"len",
"lit",
"max",
"max_horizontal",
"maybe_align_index",
"maybe_convert_dtypes",
"maybe_get_index",
"maybe_reset_index",
"maybe_set_index",
"mean",
"mean_horizontal",
"median",
"min",
"min_horizontal",
"narwhalify",
"new_series",
"nth",
"selectors",
"show_versions",
"sum",
"sum_horizontal",
"to_native",
"to_py_scalar",
"when",
]

@dangotbanned
Copy link

sorry i may have misunderstood myself - don't we have it at the bottom of the file?

__all__ = [
"Array",
"Boolean",
"Categorical",
"DataFrame",
"Date",
"Datetime",
"Duration",
"Enum",
"Expr",
"Field",
"Float32",
"Float64",
"Int16",
"Int32",
"Int64",
"Int8",
"LazyFrame",
"List",
"Object",
"Schema",
"Series",
"String",
"Struct",
"UInt16",
"UInt32",
"UInt64",
"UInt8",
"Unknown",
"all",
"all_horizontal",
"any_horizontal",
"col",
"concat",
"concat_str",
"dependencies",
"exceptions",
"from_arrow",
"from_dict",
"from_native",
"generate_temporary_column_name",
"get_level",
"get_native_namespace",
"is_ordered_categorical",
"len",
"lit",
"max",
"max_horizontal",
"maybe_align_index",
"maybe_convert_dtypes",
"maybe_get_index",
"maybe_reset_index",
"maybe_set_index",
"mean",
"mean_horizontal",
"median",
"min",
"min_horizontal",
"narwhalify",
"new_series",
"nth",
"selectors",
"show_versions",
"sum",
"sum_horizontal",
"to_native",
"to_py_scalar",
"when",
]

ah there it is 😅

@dangotbanned
Copy link

@MarcoGorelli I haven't checked the other submodules, but do these all have the same issue?

from narwhals import dependencies
from narwhals import exceptions
from narwhals import selectors

Great to see #1430

@MarcoGorelli
Copy link
Member Author

for those we already have dedicated files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers, but anyone is welcome to submit a pull request! help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants