Skip to content

wrong default value type in Schema.__init__ #22588

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

Open
2 tasks done
WH-2099 opened this issue May 3, 2025 · 2 comments · May be fixed by #22589
Open
2 tasks done

wrong default value type in Schema.__init__ #22588

WH-2099 opened this issue May 3, 2025 · 2 comments · May be fixed by #22589
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@WH-2099
Copy link

WH-2099 commented May 3, 2025

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Code

def __init__(
        self,
        schema: (
            Mapping[str, SchemaInitDataType]
            | Iterable[tuple[str, SchemaInitDataType]]
            | None
        ) = None,
        *,
        check_dtypes: bool = True,
    ) -> None:
        input = (
            schema.items() if schema and isinstance(schema, Mapping) else (schema or {})
        )
        for name, tp in input:  # type: ignore[misc]

Issue description

schma.py

The branch after else here corresponds to a schema parameter type of Iterable or None (strictly speaking, in the case of NoneType).
At the same time, the subsequent for statement indicates that the input here should be Iterable[tuple[str, SchemaInitDataType]].

Expected behavior

The default value after else should be () rather than {}.

Installed versions

--------Version info---------
Polars:              1.29.0
Index type:          UInt32
Platform:            Linux-6.14.4-arch1-1-x86_64-with-glibc2.41
Python:              3.13.3 (main, Apr  9 2025, 07:44:25) [GCC 14.2.1 20250207]
LTS CPU:             False

----Optional dependencies----
Azure CLI            <not installed>
adbc_driver_manager  <not installed>
altair               <not installed>
azure.identity       <not installed>
boto3                <not installed>
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               <not installed>
gevent               <not installed>
google.auth          <not installed>
great_tables         0.17.0
matplotlib           <not installed>
numpy                2.2.5
openpyxl             <not installed>
pandas               <not installed>
polars_cloud         <not installed>
pyarrow              <not installed>
pydantic             2.11.4
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>
@WH-2099 WH-2099 added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels May 3, 2025
@WH-2099
Copy link
Author

WH-2099 commented May 3, 2025

This is my first PR, please forgive me if there are any issues, I will follow up quickly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant