traits
traits copied to clipboard
Make traits.examples.introduction a non-package?
After #1348, traits.examples.introduction
is now a package that can be imported:
from traits.examples.introduction import *
This makes the introduction
a package and makes it look like part of the public library. But I believe the folder of Python files is also intended as data, not package.
Note that introduction
has an __init__.py
file in the introduction
folder. However I believe it was added before the etsdemo
switched to using an index.rst
file to capture the folder description (see https://github.com/enthought/traitsui/issues/849).
Note that introduction has an init.py file in the introduction folder. However I believe it was added before the etsdemo switched to using an index.rst file to capture the folder description
That is now changed by #1358.
@kitchoi It looks as though this issue can now be closed. Is that correct?
Hmmm but I can still import traits.examples.introduction
$ python3.9 -m venv ../py39-venv/traits-env-2
$ source ../py39-venv/traits-env-2/bin/activate
$ pip install .
$ cd
$ python
>>> from traits.examples import introduction
>>>
So may be we can't close it yet.
(Updated snippet as I did change directory to make sure I did not just pick up the packages from source)
but I can still import
traits.examples.introduction
I think that's just Python 3's (implicit) namespace packages at work. I don't think there's anything we can reasonably do about that.
It is true that the folder is considered a namespace package ever since the files are moved under traits
and are included as package data.
If we really want to avoid accidentally exposing public-looking packages, I think we can nest introduction
under another folder that contains a hyphen. I will leave this up to our maintainer. I mainly open the issue to describe what I observe.