Skip to content

No Python source warning for namespace modules #572

Closed
@nedbat

Description

@nedbat

Originally reported by Christian Heimes (Bitbucket: tiran, GitHub: tiran)


setuptools no longer installs a __init__.py for namespace packages. Now I'm getting a warning Coverage.py warning: Module custudia has no Python source. for a namespace package called custodia. You can easily reproduce the issue with a git checkout of https://github.com/latchset/custodia:

Reproducer:

$ git clone https://github.com/latchset/custodia.git
$ cd custodia
$ tox -e py27
...
=================================================================================== 101 passed in 11.23 seconds ====================================================================================
Coverage.py warning: Module custodia has no Python source.
_____________________________________________________________________________________________ summary ______________________________________________________________________________________________
  py27: commands succeeded
  congratulations :)

On both Python 2 and 3, a namespace module has a __path__ attribute but no __file__ attribute. May I suggest that you omit the warning when a module has no __file__ but a __path__?

$ cd /tmp
$ mkdir nsexample
$ touch nsexample/module.py
$ python3
>>> import nsexample
>>> import nsexample.module
>>> dir(nsexample)
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'module']
>>> dir(nsexample.module)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions