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

Handle dataclasses with unitialized fields in pretty printing #3418

Closed
wants to merge 3 commits into from

Conversation

CollinHeist
Copy link

@CollinHeist CollinHeist commented Jul 6, 2024

Fixes #3417

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

This is a fix for #3417. If the field has no defined attribute, then the default value should be printed instead, rather than raising an uncaught AttributeError.

@willmcgugan
Copy link
Collaborator

This probably isn't the fix. It can give the false impression that the attribute exists. Better to omit it entirely IMO.

@CollinHeist
Copy link
Author

Sure, I've made that change.

@willmcgugan
Copy link
Collaborator

Thanks, but I've gone with a slightly different solution... #3472

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.

[BUG] Dataclass attributes specified with init=False cause error in pretty printing
2 participants