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

Allow an optional separator splitting the value and unit of the result of ByteSize.human_readable. #8706

Merged
merged 5 commits into from Feb 6, 2024

Conversation

jks15satoshi
Copy link
Contributor

@jks15satoshi jks15satoshi commented Feb 2, 2024

Change Summary

Allow splitting the value and unit of the result of ByteSize.human_readable with a separator providing by the argument separator.

>>> size = ByteSize(12345678)
>>> size.human_readable()
'11.8MiB'
>>> size.human_readable(separator=' ')
'11.8 MiB'

Related issue number

fix #8668

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @adriangb

Copy link

codspeed-hq bot commented Feb 2, 2024

CodSpeed Performance Report

Merging #8706 will not alter performance

Comparing jks15satoshi:main (c3c007c) with main (8898b8f)

Summary

✅ 10 untouched benchmarks

@jks15satoshi
Copy link
Contributor Author

Please review

Copy link
Member

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

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

@jks15satoshi,

I think it'd make more sense to support a str type separator, which is an empty string by default. Could you please use that approach instead?

Thanks for your work here. Looking forward to having this new feature.

@jks15satoshi
Copy link
Contributor Author

@jks15satoshi,

I think it'd make more sense to support a str type separator, which is an empty string by default. Could you please use that approach instead?

Thanks for your work here. Looking forward to having this new feature.

OK. Changes committed.

@jks15satoshi jks15satoshi changed the title Allow optionally separating the value and unit of the result of ByteSize.human_readable by a space character. Allow an optional separator splitting the value and unit of the result of ByteSize.human_readable. Feb 3, 2024
pydantic/types.py Outdated Show resolved Hide resolved
Copy link
Member

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! So excited to have this as a new feature in our upcoming minor release :).

@sydney-runkle sydney-runkle merged commit 28ed33f into pydantic:main Feb 6, 2024
53 checks passed
@jks15satoshi
Copy link
Contributor Author

Looks great, thanks! So excited to have this as a new feature in our upcoming minor release :).

Thanks so much! It's my pleasure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ByteSize.human_readable with an optional separator (e.g. whitespace) between value and unit
3 participants