Skip to content

mypy --strict fails on scripts/packages depending on xarray; __all__ required #3695

Closed
@aldanor

Description

@aldanor

Checked this with both 0.14.1 and master branch.

Create foo.py:

from xarray import DataArray

and run:

$ mypy --strict foo.py

which results in

foo.py:1: error: Module 'xarray' has no attribute 'DataArray'
Found 1 error in 1 file (checked 1 source file)

I did a bit of digging trying to make it work, it looks like what makes the above script work with mypy is adding

__all__ = ('DataArray',)

to xarray/__init__.py, otherwise mypy treats those imports as "private" (and is correct in doing so).

Should __all__ be added to the root __init__.py? To any __init__.py in subpackages as well?

Metadata

Metadata

Assignees

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