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

[BUGFIX] Fix handling of kwargs in skip_raw decorator #396

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions promgen/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def skip_raw(func):
"""

@wraps(func)
def _wrapper(*args, raw, instance, **kwargs):
def _wrapper(*, raw=False, instance, **kwargs):
if raw:
logger.debug("Skipping %s:%s for raw %s", __name__, func.__name__, instance)
return
logger.debug("Running %s:%s for %s", __name__, func.__name__, instance)
return func(*args, raw=raw, instance=instance, **kwargs)
return func(raw=raw, instance=instance, **kwargs)

return _wrapper

Expand Down Expand Up @@ -230,17 +230,19 @@ def delete_project(sender, instance, **kwargs):

@receiver(post_save, sender=models.Service)
@skip_raw
def save_service(instance, **kwargs):
def save_service(*, sender, instance, **kwargs):
# We saving a service, we delegate the configuration reload triggering to
# the child projects which have additional information about if we need to
# write out our file or not. We call our save_project signal directly
# (instead of through post_save.save) because we don't want to trigger other
# attached signals
# We don't use sender here, but put it in our parameters so we don't pass
# two sender entries to save_project
for project in instance.project_set.prefetch_related(
'farm',
'farm__host_set',
'exporter_set'):
if save_project(sender=models.Project, instance=project):
if save_project(sender=models.Project, instance=project, **kwargs):
# If any of our save_project returns True, then we do not need to
# check any others
return True
Expand Down