Skip to content

Format 0.0 facet values consistently with other floats - #294

Merged
gvanrossum merged 1 commit into
microsoft:mainfrom
LuShadowX:fix-facet-float-zero-format
Jul 24, 2026
Merged

Format 0.0 facet values consistently with other floats#294
gvanrossum merged 1 commit into
microsoft:mainfrom
LuShadowX:fix-facet-float-zero-format

Conversation

@LuShadowX

Copy link
Copy Markdown
Contributor

When indexing a facet whose value is a float, the code formats it with :g, but the guard is isinstance(value, float) and value — the and value skips 0.0 (it's falsy), so a facet value of 0.0 gets stored as "0.0" while every other float uses :g (e.g. 2.0 -> "2"). The comment right above says "If the value is a float, we use .g format", so the extra truthiness check looks unintended.

Dropped and value in the two places that do this (add_facet and collect_facet_properties) so 0.0 is formatted like any other float ("0"). Added a small test. Full offline test suite still passes.

@LuShadowX

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This appears correct. However, I wonder why it was this way -- let me check the original TypeAgent repo.

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, TypeAgent had the correct behavior (0.0 -> "0") all along.

@gvanrossum
gvanrossum merged commit b7e7a99 into microsoft:main Jul 24, 2026
16 checks passed
@LuShadowX

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review and merge!

@LuShadowX

Copy link
Copy Markdown
Contributor Author

Thanks again for the review on this one. If there are other areas of the Python port you'd like a hand with, feel free to ping me.

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