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

Parent autoload #56

Merged
merged 5 commits into from
Jan 3, 2021
Merged

Parent autoload #56

merged 5 commits into from
Jan 3, 2021

Conversation

da-h
Copy link
Owner

@da-h da-h commented Dec 28, 2020

Parent Auto-Loading

This PR adds automatic loading of parent modules.

Example

I.e. consider the defined modules:

  • parent
  • parent2
  • parent.level1
  • parent.level1_second
  • parent.level1.level2
  • parent.level1.level2_second

Loading level2 will now load all modules that are direct parent modules of level2.
In this example mf will load (in the exact order):

  • parent
  • parent.level1
  • parent.level1.level2

Things done in this MR

  • implemented parent auto-loading as described above
  • changes printing of loaded modules for the user. previously all parent modules would be listed one after another, together with the specific module (here level1). now, it will only list parent.level1.level2, but highlight parent and level1 to show that these are modules themselves.
  • to allow special cases where this behavior is not desired, any module in the loading-chain can specify the variable register_parent = False (globally, as the register(mf) function) to disable automatic loading for this module
  • adds tests for these kind of automatic imports

@da-h da-h linked an issue Dec 28, 2020 that may be closed by this pull request
@da-h da-h force-pushed the parent_autoload branch 2 times, most recently from 9685f9b to 16742ae Compare December 28, 2020 16:13
@da-h da-h changed the base branch from v2-dev to master December 28, 2020 16:13
@da-h da-h changed the base branch from master to v2-dev December 28, 2020 16:13
@da-h da-h changed the base branch from v2-dev to master December 28, 2020 16:14
@da-h da-h changed the base branch from master to v2-dev December 28, 2020 16:14
@da-h da-h force-pushed the parent_autoload branch 2 times, most recently from 171edfa to 8f2de9a Compare December 29, 2020 11:43
@da-h da-h requested a review from sbrodehl December 29, 2020 12:18
@da-h da-h changed the title Parent autoload WIP: Parent autoload Dec 29, 2020
@da-h da-h changed the title WIP: Parent autoload Parent autoload Dec 29, 2020
@da-h da-h mentioned this pull request Dec 29, 2020
1 task
@da-h da-h added this to the v2.0 milestone Dec 29, 2020
Copy link
Collaborator

@sbrodehl sbrodehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my feedback:

  • I think the register_parents = False expression seems a little hacky, and without proper documentation might be overlooked. Is there a way to write somethings like mf.register_parents(False)?
  • IMHO the link usage for the miniflask package is bad.

@da-h da-h merged commit 19614e8 into v2-dev Jan 3, 2021
@da-h da-h deleted the parent_autoload branch January 3, 2021 12:23
da-h added a commit that referenced this pull request Jan 3, 2021
da-h added a commit that referenced this pull request Jan 4, 2021
da-h added a commit that referenced this pull request Jan 4, 2021
@da-h da-h mentioned this pull request Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoload Parent Modules
2 participants