Skip to content

Fix: Define kwargs properly for step validation#2

Merged
obarahona10 merged 1 commit intomasterfrom
fix-current-step-validation-v2.5.1
Mar 3, 2026
Merged

Fix: Define kwargs properly for step validation#2
obarahona10 merged 1 commit intomasterfrom
fix-current-step-validation-v2.5.1

Conversation

@obarahona10
Copy link
Owner

Following #1

@obarahona10 obarahona10 self-assigned this Mar 3, 2026
Copilot AI review requested due to automatic review settings March 3, 2026 12:04
@obarahona10 obarahona10 merged commit 720ea10 into master Mar 3, 2026
1 check passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts ManagementForm initialization so wizard step validation can pass steps via kwargs without conflicting with normal Form positional args (e.g., POST data), as a follow-up to #1’s current_step validation work.

Changes:

  • Update ManagementForm.__init__ to accept *args, **kwargs and pull steps from kwargs.
  • Ensure steps is stored on the instance before calling forms.Form.__init__.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.steps = steps
super().__init__(**kwargs)
def __init__(self, *args, **kwargs):
self.steps = kwargs.pop("steps", None)
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

steps is now optional (kwargs.pop("steps", None)), but clean_current_step() assumes it’s iterable; omitting steps will raise a TypeError at validation time (value not in None). Consider making steps a required kw-only argument (e.g., def __init__(..., *, steps, **kwargs)) or raise a clear error in __init__ when steps is missing/None so failures are immediate and actionable.

Suggested change
self.steps = kwargs.pop("steps", None)
self.steps = kwargs.pop("steps", None)
if self.steps is None:
raise TypeError("ManagementForm requires a 'steps' keyword argument.")
# Ensure that steps is iterable so membership checks in clean_current_step()
# do not raise a TypeError at validation time.
try:
iter(self.steps)
except TypeError as exc:
raise TypeError("ManagementForm 'steps' must be an iterable of step names.") from exc

Copilot uses AI. Check for mistakes.
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.

2 participants