Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In Python, the
__all__
object is a sequence (typically a list or tuple) that defines the public names of a module or package. When other applications install the package, the objects corresponding to the public names are exposed for direct import and use.This pull request will add
__all__
, defining the public API of the package. To start, the public API will consist of a few useful utilities that are commonly imported in other Python applications, such as the logging configuration logic and HTTP Basic auth implementations.There are some technical limitations to keep in mind when setting up
__all__
. For example, this project defines optional dependencies, including FastAPI and Starlette. If objects that use these optional dependencies are added to__all__
, but the dependencies are not installed,ImportError
exceptions will be raised. A simple solution is to wrap these imports in atry
/except
block.As another example, if objects from inboard/
start.py
are added to__all__
, and the module is then invoked withpython -m inboard.start
(as the project is currently configured to do), aRuntimeWarning
is raised. In this situation, Python potentially has two copies of the objects: one copy from inboard/__init__.py
, and one copy from inboard/start.py
. To avoid this warning, theif __name__ == "__main__"
block could be moved to inboard/__main__.py
, and Python could be invoked withpython -m inboard
instead ofpython -m inboard.start
. This could be considered in a future refactor of the project, but it is not particularly important at the moment. The inboard/start.py
module can be imported directly withimport inboard.start
.Changes
__all__
to__init__.py
(827c1c7)LOGGING_CONFIG
import in README example (b9b0f2f)Related
#3
#11
#31
#32