Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set __all__ in #176

wesbarnett opened this issue Nov 22, 2019 · 0 comments

Set __all__ in #176

wesbarnett opened this issue Nov 22, 2019 · 0 comments


Copy link

@wesbarnett wesbarnett commented Nov 22, 2019


Good morning! I think __all__ should be set in


I realize the following is not usually considered good practice, but if someone imports as follows it imports everything not prefixed with an underscore:

>>>from cmdstanpy import *
>>> dir()
['CmdStanGQ', 'CmdStanMCMC', 'CmdStanMLE', 'CmdStanModel', 'CmdStanVB', 
'STANSUMMARY_STATS', 'TMPDIR', '__annotations__', '__builtins__', '__doc__', '__loader__', 
'__name__', '__package__', '__spec__', 'atexit', 'cleanup_tmpdir', 'cmdstan_args', 'cmdstan_path',
'install_cmdstan', 'model', 'set_cmdstan_path', 'set_make_env', 'shutil', 'stanfit', 'tempfile', 'utils']

To solve this either __all__ can be set explicitly to those items that the project wants exported for the "public API".

For example, it could be set as:

__all__ = ['set_cmdstan_path', 'cmdstan_path', 'set_make_env',
            'install_cmdstan', 'set_cmdstan_path', 'CmdStanMLE', 'CmdStanGQ',
            'CmdStanVB', 'CmdStanModel' ]

Alternatively it could be set to an empty list indicating the module is not designed for this type of import statement:

__all__ = []

In this case the module can still be imported as usual with:

import cmdstanpy

or one can indicate what to import explicitly:

from cmdstanpy import cmdstan_path

Here is the PEP8 reference.

Current Version:

master branch (0.6.0)

@wesbarnett wesbarnett changed the title Set `__all__` in `` Set __all__ in Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.