user_manager.py: Support alternative managers passed to init_app() #334
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.
Currently, we can call init_pp() and then overwrite the managers afterward, but this a) requires us to interfere with the semantics of the UserManager object in a way that might affect upgradeability (or, conversely, your ability to make changes while avoiding those issues), and b) can't avoid side-effects related to those initial instances. For example, I might create a custom DbManager and assign it into the UM object but other references to the original UM object remain elsewhere. So, part of the flow will be using the old instance and part of the flow will be using the new instance.
This is the point of providing accessors but leaving the members/attributes of the class to be exclusively established by the internal logic of the class. I, as a consumer of the class/project, should have a path forward in customizing what I need to via parameters, and you, as maintainer of the class/project, should have a path forward to be able to make changes to the shape/flow of the project without being prevented from doing so because I've interfered in a scope that I shouldn't have had to.
TLDR: This is a minor change to allow the main managers to be overridden via constructor. I attempted to run the tests but it failed with the same issue that's currently plaguing the CI tests.