Skip to content

Avoid invoking default factories when rendering transforms - #558

Open
xiehuanyi wants to merge 1 commit into
alecthomas:masterfrom
xiehuanyi:fix/voluptuous-factory-repr
Open

xiehuanyi wants to merge 1 commit into
alecthomas:masterfrom
xiehuanyi:fix/voluptuous-factory-repr

Conversation

@xiehuanyi

Copy link
Copy Markdown

repr(DefaultTo(factory)) and repr(SetTo(factory)) currently invoke the factory. Printing a schema can therefore consume a sequence, produce a random value, or fail before validation runs.

Retain the original constructor argument for the representation and keep the existing factory for validation. Representing literal defaults stays the same. Add regressions that count factory calls and use a factory that raises if called outside validation.

Validation: all four new regressions fail on unchanged master. The complete test suite passes after the fix (186 tests), with Flake8/doctests and Black checks passing.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 11:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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