Skip to content

__init__.py is created for dependencies, and can break them #3

@stevendee-recon

Description

@stevendee-recon

E.g.: https://github.com/stevendee-recon/py-repro

That code runs fine (erroring on the invalid Company construction) if run via:

python3 -m venv venv
./venv/bin/pip3 install edgartools
./venv/bin/python app

But fails with an ImportError if run via either:

bazel run //app:app_bin

or

bazel run //app:app_bin.venv
source .app+app_bin.venv/bin/activate
python app

edgartools contains both edgar/entity/data.py and edgar/entity/data/. Apparently @rules_python populates a __init__.py under edgar/entity/data, which breaks anything that transitively imports anything out of edgar.entity.data.

My coding assistant tells me that setting enable_implicit_namespace_pkgs = True on the pip.parse in MODULE.bazel works around the issue. I’m not sure if that’s a straightforward fix or if it will break other things.

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