8000 change secret types example (#890) · ag-python/pydantic@b1e61b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1e61b4

Browse files
ashearssamuelcolvin
authored andcommitted
change secret types example (pydantic#890)
* change secret types example * add changes file * add address review comments * remove redundant str() call
1 parent c3098a3 commit b1e61b4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

changes/890-ashears.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
change secret types example

docs/examples/ex_secret_types.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ class SimpleModel(BaseModel):
55
password_bytes: SecretBytes
66

77
sm = SimpleModel(password='IAmSensitive', password_bytes=b'IAmSensitiveBytes')
8+
9+
# Standard access methods will not display the secret
810
print(sm)
11+
print(sm.password)
12+
print(sm.json())
913

14+
# Use get_secret_value method to see the secret's content.
1015
print(sm.password.get_secret_value())
1116
print(sm.password_bytes.get_secret_value())
12-
print(sm.password.display())
13-
print(sm.json())
1417

1518
try:
1619
SimpleModel(password=[1, 2, 3], password_bytes=[1, 2, 3])

0 commit comments

Comments
 (0)
0