8000 Use `b64decode` and `b64encode` for `Base64Bytes` type by sydney-runkle · Pull Request #10486 · pydantic/pydantic · GitHub 8000
[go: up one dir, main page]

Skip to content

Conversation

@sydney-runkle
Copy link
Contributor

Closes #9072

Change that should be highlighted in the upcoming release notes + blog post.

@sydney-runkle sydney-runkle added the relnotes-change Used for changes to existing functionality which don't have a better categorization. label Sep 25, 2024
@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Sep 25, 2024
@cloudflare-workers-and-pages
Copy link
cloudflare-workers-and-pages bot commented Sep 25, 2024

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3b80ba9
Status: ✅  Deploy successful!
Preview URL: https://617bf15e.pydantic-docs.pages.dev
Branch Preview URL: https://base-64-bytes-fix.pydantic-docs.pages.dev

View logs

@codspeed-hq
Copy link
codspeed-hq bot commented Sep 25, 2024

CodSpeed Performance Report

Merging #10486 will not alter performance

Comparing base-64-bytes-fix (3b80ba9) with main (c7497c5)

Summary

✅ 38 untouched benchmarks

@sydney-runkle
Copy link
Contributor Author

One lingering concern that I have here is the failing test relating to round tripping:

from pydantic import BaseModel, Base64Bytes

input_data = b'Zm9vIGJhcg==\n'
expected_value = b'foo bar'

class Model(BaseModel):
    base64_value: Base64Bytes

m = Model(base64_value=input_data)
assert m.base64_value == expected_value

assert m.model_dump()['base64_value'] == input_data
# b'Zm9vIGJhcg==' != b'Zm9vIGJhcg==\n'

cc @Viicos, @dmontagu

@Viicos Viicos changed the title Use up to date base64 encoder / decoder Use b64decode and b64encode for Base64Bytes type Sep 25, 2024
@sydney-runkle sydney-runkle removed the relnotes-fix Used for bugfixes. label Sep 25, 2024
@sydney-runkle
Copy link
Contributor Author

One lingering concern that I have here is the failing test relating to round tripping.

We've discussed - this isn't an issue, the whole point was to move to the newer function not adding a newline automatically. Validation still succeeds, so round tripping is fine. This is similar to url behavior, etc.

@github-actions
Copy link
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  types.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Member
@Viicos Viicos left a comment

Choose a reason for hiding this comment

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

nice!

@sydney-runkle sydney-runkle merged commit e838139 into main Sep 26, 2024
@sydney-runkle sydney-runkle deleted the base-64-bytes-fix branch September 26, 2024 14:29
@woodruffw
Copy link
Contributor

Thank you @sydney-runkle, this is fantastic!

commonism added a commit to commonism/aiopenapi3 that referenced this pull request Jan 11, 2025
commonism added a commit to commonism/aiopenapi3 that referenced this pull request Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review relnotes-change Used for changes to existing functionality which don't have a better categorization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Base64Bytes with newlines

4 participants

0