Skip to content

change secret types example#890

Merged
samuelcolvin merged 5 commits intopydantic:masterfrom
ashears:master
Oct 14, 2019
Merged

change secret types example#890
samuelcolvin merged 5 commits intopydantic:masterfrom
ashears:master

Conversation

@ashears
Copy link
Copy Markdown
Contributor

@ashears ashears commented Oct 11, 2019

Change Summary

I was examining #884, which discussed the secret types. I found that the example for secret types could be slightly more clear.

Apologies if I am in error with creating this PR, I do not have experience submitting PR to an open source code base.

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 11, 2019

Codecov Report

Merging #890 into master will not change coverage.
The diff coverage is n/a.

@@          Coverage Diff          @@
##           master   #890   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          16     16           
  Lines        2716   2742   +26     
  Branches      518    521    +3     
=====================================
+ Hits         2716   2742   +26
Impacted Files Coverage Δ
pydantic/error_wrappers.py 100% <0%> (ø) ⬆️
pydantic/types.py 100% <0%> (ø) ⬆️
pydantic/fields.py 100% <0%> (ø) ⬆️
pydantic/typing.py 100% <0%> (ø) ⬆️
pydantic/utils.py 100% <0%> (ø) ⬆️
pydantic/networks.py 100% <0%> (ø) ⬆️
pydantic/schema.py 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7227db...812e8ed. Read the comment docs.

@ashears ashears marked this pull request as ready for review October 11, 2019 22:44
@dmontagu
Copy link
Copy Markdown
Contributor

Looks good to me

changes/-.md file added describing change
(see changes/README.md for details)

Feel free to do this if you want credit for your contribution!

Copy link
Copy Markdown
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

looks good, but a few small things to change.

Maybe best for me to merge #884 and the PR which changes how print works in examples, which I'm working on today.

Comment thread docs/examples/ex_secret_types.py Outdated
# Standard access methods will not display the secret
print(sm)
#> SimpleModel password=SecretStr('**********') password_bytes=SecretBytes(b'**********')
# > SimpleModel password=SecretStr('**********') password_bytes=SecretBytes(b'**********')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# > SimpleModel password=SecretStr('**********') password_bytes=SecretBytes(b'**********')
#> SimpleModel password=SecretStr('**********') password_bytes=SecretBytes(b'**********')

and below.

Comment thread docs/examples/ex_secret_types.py Outdated
print(sm)
#> SimpleModel password=SecretStr('**********') password_bytes=SecretBytes(b'**********')
# > SimpleModel password=SecretStr('**********') password_bytes=SecretBytes(b'**********')
print(sm.password.display())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

.display() is deprecated after #884 which will be merged before this (try to merge in the order PRs are created unless there's a good reason not to)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to print(str(sm.password))

Copy link
Copy Markdown
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

otherwise LGTM.

Comment thread docs/examples/ex_secret_types.py Outdated

# Standard access methods will not display the secret
print(sm)
print(str(sm.password))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
print(str(sm.password))
print(repr(sm.password))

print(str(x)) is the same as print(x)

@samuelcolvin samuelcolvin merged commit b1e61b4 into pydantic:master Oct 14, 2019
@samuelcolvin
Copy link
Copy Markdown
Member

thank you very much.

andreshndz pushed a commit to cuenca-mx/pydantic that referenced this pull request Jan 17, 2020
* change secret types example

* add changes file

* add address review comments

* remove redundant str() call
alexdrydew pushed a commit to alexdrydew/pydantic that referenced this pull request Dec 23, 2023
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.

3 participants