Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnl committed Feb 5, 2024
1 parent 606fa40 commit 08dcce2
Show file tree
Hide file tree
Showing 7 changed files with 2,669 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/concepts/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def extract(data) -> UserDetail:
start = time.perf_counter() # (1)
model = extract("Extract jason is 25 years old")
print(f"Time taken: {time.perf_counter() - start}")
#> Time taken: 0.5028559579513967
#> Time taken: 0.6282629589550197

start = time.perf_counter()
model = extract("Extract jason is 25 years old") # (2)
print(f"Time taken: {time.perf_counter() - start}")
#> Time taken: 1.0831281542778015e-06
#> Time taken: 1.9171275198459625e-06
```

1. Using `time.perf_counter()` to measure the time taken to run the function is better than using `time.time()` because it's more accurate and less susceptible to system clock changes.
Expand Down
13 changes: 3 additions & 10 deletions docs/concepts/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ These all work as great opportunities to add more information to the JSON schema
Here's an example:

```py
from pydantic import BaseModel, EmailStr, Field, SecretStr
from pydantic import BaseModel, Field, SecretStr


class User(BaseModel):
age: int = Field(description='Age of the user')
email: EmailStr = Field(examples=['[email protected]'])
name: str = Field(title='Username')
password: SecretStr = Field(
json_schema_extra={
Expand All @@ -121,12 +120,6 @@ print(User.model_json_schema())
{
'properties': {
'age': {'description': 'Age of the user', 'title': 'Age', 'type': 'integer'},
'email': {
'examples': ['[email protected]'],
'format': 'email',
'title': 'Email',
'type': 'string',
},
'name': {'title': 'Username', 'type': 'string'},
'password': {
'description': 'Password of the user',
Expand All @@ -137,14 +130,14 @@ print(User.model_json_schema())
'writeOnly': True,
},
},
'required': ['age', 'email', 'name', 'password'],
'required': ['age', 'name', 'password'],
'title': 'User',
'type': 'object',
}
"""
```

## General notes on JSON schema generation
# General notes on JSON schema generation

- The JSON schema for Optional fields indicates that the value null is allowed.
- The Decimal type is exposed in JSON schema (and serialized) as a string.
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def print_iterable_results():
async for m in model:
print(m)
#> name='John Doe' age=30
#> name='Jane Doe' age=35
#> name='Jane Smith' age=25


import asyncio
Expand Down
Loading

0 comments on commit 08dcce2

Please sign in to comment.