No Python source warning for namespace modules

Issue #572 resolved
Christian Heimes
created an issue

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__']

Comments (4)

  1. Christian Heimes reporter

    https://github.com/tiran/covns is a minimal reproducer for the problem

    GLOB sdist-make: .../covns/setup.py
    py27 inst-nodeps: .../covns/.tox/dist/covns-0.1.zip
    py27 installed: appdirs==1.4.3,coverage==4.3.4,covns==0.1,packaging==16.8,py==1.4.33,pyparsing==2.2.0,pytest==3.0.7,six==1.10.0
    py27 runtests: PYTHONHASHSEED='388494413'
    py27 runtests: commands[0] | .../covns/.tox/py27/bin/python -m coverage run --parallel -m pytest --capture=no --strict
    =============================================================== test session starts ===============================================================
    platform linux2 -- Python 2.7.13, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
    rootdir: .../covns, inifile: tox.ini
    collected 1 items 
    
    tests.py .
    
    ============================================================ 1 passed in 0.02 seconds =============================================================
    Coverage.py warning: Module covns has no Python source.
    _____________________________________________________________________ summary _____________________________________________________________________
      py27: commands succeeded
      congratulations :)
    
  2. Log in to comment