Skip to content

import errors with native namespace packages #464

@wochinge

Description

@wochinge

Hi,

we have a code base with native namespace packages.
It has the following structure:

src/
    subpackage_a
        namespace
            # no __init__.py here!
            subpackage_a
    subpackage_b
        namespace
            # no __init__.py here!
            subpackage_b

When I run pytype --keep-going src/subpackage_a/namespace, the type checking fails with a ton of import errors.

As soon as I add __init__.py files to the namespace packages (can be empty or pkgutil style), and then run the same command, the pytype check succeeds. The same happens if I run pytype -k src/subpackage_a/namespace/subpackage_a.

After adding the __init__.py files, I have the following structure:

src/
    subpackage_a
        namespace
            __init__.py
            subpackage_a
    subpackage_b
        namespace
            __init__.py
            subpackage_b

pytype version: 2019.11.27
python version: 3.7.5
OS: MacOS catalina

I know this is probably hard to reproduce for you, but I'd really appreciate any hints on that. Thanks a lot for your help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions