-
Notifications
You must be signed in to change notification settings - Fork 3
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
how to make sample code runnable ? #333
Comments
https://github.com/samuelcolvin/mkdocs-run- The configuration that makes the code examples runnable in your MkDocs setup is the inclusion of an external JavaScript file specifically designed for making code blocks interactive: extra_javascript:
- 'extra/fluff.js'
- 'https://samuelcolvin.github.io/mkdocs-run-code/run_code_main.js' In this part of your MkDocs configuration, the Ensure that you have set up everything necessary for the |
from datetime import datetime
from pydantic import BaseModel, PositiveInt
class User(BaseModel):
id: int # (1)!
name: str = 'John Doe' # (2)!
signup_ts: datetime | None # (3)!
tastes: dict[str, PositiveInt] # (4)!
external_data = {
'id': 123,
'signup_ts': '2019-06-01 12:22', # (5)!
'tastes': {
'wine': 9,
b'cheese': 7, # (6)!
'cabbage': '1', # (7)!
},
}
user = User(**external_data) # (8)!
print(user.id) # (9)!
#> 123
print(user.model_dump()) # (10)!
"""
{
'id': 123,
'name': 'John Doe',
'signup_ts': datetime.datetime(2019, 6, 1, 12, 22),
'tastes': {'wine': 9, 'cheese': 7, 'cabbage': 1},
}
""" |
The text was updated successfully, but these errors were encountered: