Skip to content

Import statement unexpectedly executes functions in __init__.py  #497

@ndrluis

Description

@ndrluis

Apache Iceberg version

None

Please describe the bug 🐞

When we import any functions that reside in __init__.py, it triggers the execution of the code instead of merely importing it. We must relocate the functions to a different file and manage the imports in __init__.py using the __all__ variable. This approach enables both star imports and specific imports without running the code upon import, thereby providing isolation between the internal and public API.

Examples:

AWS SDK for Pandas
Pandas Arrays
Scikit-Learn Datasets

More info:

Python.org: Packages
Python.org: Importing from a Package

This is causing me problems with the CLI I'm building as an internal tool. Can I be responsible for fixing this behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions