Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Minor fix for Field.__repr__ #114

Merged
merged 1 commit into from
Feb 17, 2024
Merged

Conversation

eltbus
Copy link
Contributor

@eltbus eltbus commented Feb 16, 2024

Don't call __len__ on a None value.

@@ -304,7 +304,7 @@ def __eq__(self, other: object) -> bool:
return NotImplemented

def __repr__(self) -> str:
if len(self.value) > 97:
if self.value is not None and len(self.value) > 97:
Copy link
Owner

Choose a reason for hiding this comment

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

How self.value can be None?

Copy link
Contributor Author

@eltbus eltbus Feb 16, 2024

Choose a reason for hiding this comment

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

If set by Field.set_none.

It is also type hinted in the property Field.value here:

    @property
    def value(self) -> bytes | None:

@Kludex
Copy link
Owner

Kludex commented Feb 17, 2024

Thanks!

@Kludex Kludex merged commit a437ebc into Kludex:master Feb 17, 2024
6 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants