Skip to content

Commit

Permalink
🪛 Fix docs and removed redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsil committed Apr 22, 2023
1 parent b4f69e9 commit c12ef46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/migrations/discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ When no `--app` or no `SAFFIER_DEFAULT_APP` environment variable is provided, Sa
exception.

* Once one of those files is found, Saffier will analised the type of objects contained in the
module and will check if any of them is a valid `Saffier` type and return it.
module and will check if any of them contains the `Migration` object attached and return it.

* If Saffier understand that none of those objects are type `Saffier` (or subclasses), it will
* If Saffier understand that none of those objects contain the `Migration`, it will
do one last attempt and try to find specific function declarations:
* **get_application()**
* **get_app()**
Expand Down
21 changes: 11 additions & 10 deletions saffier/migrations/operations/shell/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)


def welcome_message(app: Any):
def welcome_message(app: Any) -> None:
"""Displays the welcome message for the user"""
now = datetime.datetime.now().strftime("%b %d %Y, %H:%M:%S")
saffier_info_date = f"Saffier {saffier.__version__} (interactive shell, {now})"
Expand Down Expand Up @@ -53,24 +53,25 @@ def import_defaults():
printer.write_success(directive, colour=OutputColour.CYAN3)
imported_objects[name] = module

def import_models():
# Creates a dict map with module path and model to import
printer.write_success("Models".center(79, "-"), colour=OutputColour.CYAN3)
for _, model in sorted(registry.models.items()):
def _import_objects(lookup_dict: Dict[Any, Any]) -> Any:
for _, model in sorted(lookup_dict.items()):
directive = import_statement.format(module_path=model.__module__, model=model.__name__)
printer.write_success(directive, colour=OutputColour.CYAN3)
imported_objects[model.__name__] = model

def import_models():
if not registry.models:
return

printer.write_success("Models".center(79, "-"), colour=OutputColour.CYAN3)
_import_objects(registry.models)

def import_reflected_models():
# Creates a dict map with module path and model to import
if not registry.reflected:
return

printer.write_success("Reflected models".center(79, "-"), colour=OutputColour.CYAN3)
for _, model in sorted(registry.reflected.items()):
directive = import_statement.format(module_path=model.__module__, model=model.__name__)
printer.write_success(directive, colour=OutputColour.CYAN3)
imported_objects[model.__name__] = model
_import_objects(registry.reflected)

import_defaults()
import_models()
Expand Down

0 comments on commit c12ef46

Please sign in to comment.