Skip to content

Commit b850ad1

Browse files
resolve nested code fence line numbering (#182)
1 parent e529615 commit b850ad1

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

docs/index.md

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ print(Settings().model_dump())
313313
1. Sub model has to inherit from `pydantic.BaseModel`, Otherwise `pydantic-settings` will initialize sub model,
314314
collects values for sub model fields separately, and you may get unexpected results.
315315

316-
1. Sub model has to inherit from `pydantic.BaseModel`, Otherwise `pydantic-settings` will initialize sub model,
316+
2. Sub model has to inherit from `pydantic.BaseModel`, Otherwise `pydantic-settings` will initialize sub model,
317317
collects values for sub model fields separately, and you may get unexpected results.
318318

319319
`env_nested_delimiter` can be configured via the `model_config` as shown above, or via the
@@ -389,29 +389,25 @@ Once you have your `.env` file filled with variables, *pydantic* supports loadin
389389

390390
1. Setting the `env_file` (and `env_file_encoding` if you don't want the default encoding of your OS) on `model_config`
391391
in the `BaseSettings` class:
392+
````py hl_lines="4 5"
393+
from pydantic_settings import BaseSettings, SettingsConfigDict
392394

393-
```py hl_lines="4 5"
394-
from pydantic_settings import BaseSettings, SettingsConfigDict
395-
396-
397-
class Settings(BaseSettings):
398-
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8')
399-
```
400395

396+
class Settings(BaseSettings):
397+
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8')
398+
````
401399
2. Instantiating the `BaseSettings` derived class with the `_env_file` keyword argument
402400
(and the `_env_file_encoding` if needed):
401+
````py hl_lines="8"
402+
from pydantic_settings import BaseSettings, SettingsConfigDict
403403

404-
```py hl_lines="8"
405-
from pydantic_settings import BaseSettings, SettingsConfigDict
406-
407-
408-
class Settings(BaseSettings):
409-
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8')
410404

405+
class Settings(BaseSettings):
406+
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8')
411407

412-
settings = Settings(_env_file='prod.env', _env_file_encoding='utf-8')
413-
```
414408

409+
settings = Settings(_env_file='prod.env', _env_file_encoding='utf-8')
410+
````
415411
In either case, the value of the passed argument can be any valid path or filename, either absolute or relative to the
416412
current working directory. From there, *pydantic* will handle everything for you by loading in your variables and
417413
validating them.
@@ -476,22 +472,19 @@ super_secret_database_password
476472
Once you have your secret files, *pydantic* supports loading it in two ways:
477473

478474
1. Setting the `secrets_dir` on `model_config` in a `BaseSettings` class to the directory where your secret files are stored.
475+
````py hl_lines="4 5 6 7"
476+
from pydantic_settings import BaseSettings, SettingsConfigDict
479477

480-
```py hl_lines="4 5 6 7"
481-
from pydantic_settings import BaseSettings, SettingsConfigDict
482-
483-
484-
class Settings(BaseSettings):
485-
model_config = SettingsConfigDict(secrets_dir='/var/run')
486478

487-
database_password: str
488-
```
479+
class Settings(BaseSettings):
480+
model_config = SettingsConfigDict(secrets_dir='/var/run')
489481

482+
database_password: str
483+
````
490484
2. Instantiating the `BaseSettings` derived class with the `_secrets_dir` keyword argument:
491-
492-
```
493-
settings = Settings(_secrets_dir='/var/run')
494-
```
485+
````
486+
settings = Settings(_secrets_dir='/var/run')
487+
````
495488

496489
In either case, the value of the passed argument can be any valid directory, either absolute or relative to the
497490
current working directory. **Note that a non existent directory will only generate a warning**.

0 commit comments

Comments
 (0)