sphinx_theme_builder._internal.cli
calls sys.exit()
on module import, breaking pydoc, module introspection
#40
Unanswered
ferdnyc
asked this question in
Potential Issue
Replies: 1 comment 3 replies
-
Why are you importing an |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If a project dependency is missing, the
__init__.py
forsphinx_theme_builder._internal.cli
will callsys.exit(1)
on import, making it impossible to examine the module via normal Python introspection tools likeimportlib.import_module()
orpydoc
.Worse, a user who attempts to run a documentation keyword search from the command line using
pydoc -k <keyword>
will find their scan abruptly terminates as soon as pydoc reaches the module.Even just typing
import sphinx_theme_builder._internal.cli
in a REPL will instantly drop the user out of their Python session, destroying any and all work they'd done with it up to that point:sys.exit()
should only ever be called either inside a function (which isn't executed on import), or when inside anif __name__ == '__main__':
conditional block. It's never OK to take down the entire interpreter with anexit()
call at the module level, where it can be executed on import. (Especially for "optional" dependencies!) Following that rule is just part of being a polite and respectful member of the package ecosystem.Beta Was this translation helpful? Give feedback.
All reactions