[omm] deplopulate __init__ and delint #1368
Merged
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.
Summary
Depopulating
__init__.py
A bunch of the lint tools were behaving strangely because they were getting confused about contents of the project based on the behavior of the
__init__.py
module.__init__.py
is special in that its executed whenever you import subprojects (import a.b executes a.init.py).Putting the flask application creation factory (
create_app
) in__init__.py
is initially convenient because it means the factory is always at the top level of the init, however it introduces a lot of potential for errors (I've cut myself with__init__.py
enough that I now prefer to leave them empty).How flask finds the right app is described in https://flask.palletsprojects.com/en/2.3.x/cli/#application-discovery
The other common place to put it is in app.py.
As part of this work, I also tried to remove all the module-level work that was being done, but specifically for the "db" object, this doesn't appear to be possible due to the design of flask-sqlalchemy.
I decided to just arbitrary shuffle the database information all into one place (models and all).
Delint
emptying
__init__.py
allowed me to delint the rest of app, which were mostly small fixes.Test Plan
mypy . && py.test
LINT SHOULD NOW BE GREEN!