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

Fix repr for Fields that don't define default. (Cherry-pick of #18719) #18724

Merged
merged 1 commit into from
Apr 13, 2023

Conversation

danxmoran
Copy link
Contributor

Found while working on #18566

The code for Field declares that subclasses must define one of default and required, and leaves default without a value. However its implementation of __repr__ assumes that default will always be defined. This can cause errors like:

AttributeError: 'RequiredField' object has no attribute 'default'

In various places, i.e. when stringifying a FieldSet or when converting a Target to a FieldSet via field_set_type.create(tgt).

Found while working on pantsbuild#18566

The code for `Field` declares that subclasses must define one of
`default` and `required`, and leaves `default` without a value. However
its implementation of `__repr__` assumes that `default` will always be
defined. This can cause errors like:
```
AttributeError: 'RequiredField' object has no attribute 'default'
```
In various places, i.e. when stringifying a `FieldSet` or when
converting a `Target` to a `FieldSet` via `field_set_type.create(tgt)`.
@danxmoran danxmoran added the category:bugfix Bug fixes for released features label Apr 12, 2023
@danxmoran danxmoran added this to the 2.16.x milestone Apr 12, 2023
@danxmoran danxmoran merged commit a00ceed into pantsbuild:2.16.x Apr 13, 2023
@danxmoran danxmoran deleted the cherry-pick-18719-to-2.16.x branch April 13, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants