Skip to content

Enhancement: Support top-level lazy subpackage imports #3265

@petermkr

Description

@petermkr

The Zarr subpackages (like storage) are not referenced directly in the top-level package's __init__.py.

This leads to warnings in static code analyzers when using snippets of the form:

import zarr
store = zarr.storage.LocalStore('...')

For example, here is a warning from IntelliJ:

Image

It is of course possible to use different imports; however, this kind of import is quite beneficial in situations where different storage providers are used side by side (e.g. Xarray) so that having an explicit reference makes it unambiguous which provider is used.

PEP 562 proposes a solution to support these kinds of imports natively, using the __getattr__ function in modules. NumPy and SciPy both use this pattern.

If you agree that this is a good idea, I can happily contribute a pull request (probably quite similar to SciPy's solution).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy