Releases: da-h/miniflask
Releases · da-h/miniflask
Miniflask v2.2.0
Miniflask v2.1.0
What's Changed
Full Changelog: v2.0.0...v2.1.0
Miniflask v2.0
This release marks a major version jump of the miniflask framework.
(Check out #75 in case you want a list of all PRs and Issues that went into this release.)
Your miniflask v1 code will not work out of the box with this release.
- Read the migration notes below.
- Please, pay close attention to all changes that have been made.
Major Changes
- Documentation: (see PR #69)
- API-Reference added.
- some chapters are now rewritten
- Module Inheritance: (see PR #48)
- enabled submodules (modules with modules beneath it)
- changed the way relative modules are referenced
- relative module ids can now be for all functions that require module ids (e.g.
register_default_module
to register a submodule as default specialization) - this makes the module identifier keyword
default
obsolete, thus this feature has been removed mf.any_child_loaded
checks dynamically if a submodule has been loaded already (see PR #60)
- Parent autoload: (see PR #56)
- All parent modules load automatically before loading the actual requested module.
(This allows grouped modules to share functionality in parent modules.)
Note: Disabling autoloading can be done using a global variable namedregister_parent = False
.
- All parent modules load automatically before loading the actual requested module.
- Fuzzy Variable Matching: (see PR #51)
- The search order of fuzzy variable matching (
state["var"]
calls or CLI-arguments) has changed. Starting with the most special versions of the call, the search traverses to the global variables. - Matches are cached to reduce query-time.
del state["var"]
statements now clear the cache.
- The search order of fuzzy variable matching (
- Events:
- Any event can now be called with an
mf
argument. This enables dynamic event registration during other events, i.e. usingmf.register_mf(..)
. (see PR #58) mf.overwrite_event
andmf.unregister_event
are two additional dynamic event registration methods that can be used at any time- before/after-events API changed and does not require the events to match a specific function signatures anymore (see #74)
- changed default call from
register_event(...,unique=False)
toregister_event(...,unique=True)
(see #65) - now any function gets wrapped in case before/after-event or altfn-option is requested by the user (see #62)
- Any event can now be called with an
Minor Changes
miniflask.init
now allowsPosixPath
argumentsevent
andstate
objects are tightly bound to the specific miniflask object, thus deepcopying those is disabled from now.- This Repo now comes with Unit-Tests to ensure consistency and to prevent accidental API-Changes
- Like- & lambda expressions now check for circular dependencies
Bugfixes
- Argparse:
- the negative scientific notation can now be used as numeric values
- single dash-arguments have been removed for more consistent CLI-parsing (see PR #47)
- Import:
- Rewrite of module imports to enable testing.
- (Python import interfered with multiple miniflask instances.)
- Previously, the import was based on modifying
sys.path
. Now, import is based on Python'simportlib
module.
- cases where the
__init__.py
file of a module was inaccessible have lead to bugs
- Rewrite of module imports to enable testing.
- Exceptions:
- Did not showed
raise
line of exception in some cases - Hiding internal calls from the exception message has lead to some bugs that have been resolved in this PR
- Did not showed
- event-calls with
outervar
and optional arguments could interfere in some cases - The predefined module
[modules]
now lists submodules as well. get_default_args
should not returnNone
-arguments (as they cannot be registered for CLI)- fixed Boolean list default values
Migration Notes (coming from v1.35
)
Code built with Miniflask v1 probably will not work out of the box with Miniflask v2.
- Module Inheritance: (see PR #48)
- With that change, the module identifier keyword
default
is not needed anymore, and thus, has been removed.- In most cases, it is sufficient to move the contents of
modulename/default/*
tomodulename/*
(especially & including the__init__.py
file.
- In most cases, it is sufficient to move the contents of
- Relative module identifiers where defined without submodules in mind, thus modules where interpreted as files. Specifying a sibling module (say
siblingmodule
) the relative identifier was.siblingmodule
. Getting the sibling one directory up could be specified using an additional dot, i.e...siblingmodule
. To adapt this notation to submodules, i.e. specifying modules below the current directory, the notation got an offset for relative module paths. The new notation is..siblingmodule
for a sibling,...siblingmodule
for a sibling of the parent directory,.childmodule
for a submodule. - All this makes most uses of
set_scope
orredefine_scope
obsolete. Please consider restructuring the modules that usese one of those features. - Relative module ids work now with all functions that require module ids. Relative module ids can help to maintain portability of modules into other module repositories. Thus, consider rewriting your repository to use that feature.
- With that change, the module identifier keyword
- Parent autoload:
- Previous versions did not allow submodules, thus this new feature should not interefere with old code bases.
- If however, your code did call some kind of parent module loading (i.e. using
default
-keyworded modules), these calls may need to be rewritten. - Consider the function
mf.any_child_loaded
to specify “default“-parameter queries/module loading-calls in case of grouped modules.
- Fuzzy Variable Matching:
Previous fuzzy variable matching (in CLI or instate["varname"]
calls) started with the most special version of the match, then proceeded to global matches in case no match was found and then descentedt into all other modules.
This search order has changed significantly. For instance, global matches are now last in the search order. Please consider the PR #51 for more details. - Events:
mf.register_event
registers any event asunique
by default now. Previously it has registered a non-unique event by default.- Hacky code-snippets to define new events inside event-callcs are not required anymore and should be replaced with
mf.register_event
-calls (or similar). - the
before
/after
-event API has changed significantly. Please check the documentation on how to modify arguments of event-calls and their results.