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

[FEATURE] Bigger, better, SecretStr #165

Open
dannymeijer opened this issue Jan 31, 2025 · 0 comments · May be fixed by #164
Open

[FEATURE] Bigger, better, SecretStr #165

dannymeijer opened this issue Jan 31, 2025 · 0 comments · May be fixed by #164
Labels
enhancement New feature or request

Comments

@dannymeijer
Copy link
Member

We should create a custom SecretStr implementation that plays a bit nicer with str operations, but that's up for debate.

For example, this code would throw an error:

from pydantic import SecretStr
body = SecretStr("foobarbazbladibla")
type = "bearer"
header = type + body

results in TypeError: unsupported operand type(s) for +: 'SecretStr' and 'str'

using f-string notation also doesn't work nicely:

header = f"{type} {body}"

you don't get an error doing this, but the resulting type of header will be str and will be set to 'bearer **********'. The resulting str also seems to be 'broken' in that you can't run type against it for example.

Long story short, we should make 'adding' things (prefixing of suffixes) something to a given SecretStr easy as well.

@dannymeijer dannymeijer added the enhancement New feature or request label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant