Skip to content

Commit c2c74e8

Browse files
Update the template for BlackSheep v2
- Update the template for BlackSheep v2 - Remove support for Pydantic v1, add support for `pydantic-settings`, and upgrade `Pydantic` pinned version
1 parent 7761028 commit c2c74e8

4 files changed

Lines changed: 27 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## 2023-11-26
9+
- Update the template for BlackSheep v2
10+
- Remove support for Pydantic v1, add support for `pydantic-settings`,
11+
and upgrade `Pydantic` pinned version
12+
13+
## 2023-06-29 :gem:
14+
- New project template

{{cookiecutter.project_name}}/app/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def configure_application(
2121
services=services, show_error_details=settings.app.show_error_details
2222
)
2323

24+
25+
2426
configure_error_handlers(app)
2527
configure_authentication(app, settings)
2628
{%- if cookiecutter.use_openapi %}

{{cookiecutter.project_name}}/app/settings.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
88
https://docs.pydantic.dev/latest/usage/settings/
99
"""
10-
from pydantic import BaseModel, BaseSettings
10+
from pydantic import BaseModel
11+
from pydantic_settings import BaseSettings, SettingsConfigDict
1112

1213

1314
class APIInfo(BaseModel):
14-
title = "{{ cookiecutter.project_name }} API"
15-
version = "0.0.1"
15+
title: str = "{{ cookiecutter.project_name }} API"
16+
version: str = "0.0.1"
1617

1718

1819
class App(BaseModel):
19-
show_error_details = False
20+
show_error_details: bool = False
2021

2122

2223
class Site(BaseModel):
@@ -32,8 +33,7 @@ class Settings(BaseSettings):
3233
# export app_app='{"show_error_details": True}'
3334
app: App = App()
3435

35-
class Config:
36-
env_prefix = "APP_" # defaults to no prefix, i.e. ""
36+
model_config = SettingsConfigDict(env_prefix='APP_')
3737

3838

3939
def load_settings() -> Settings:
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
blacksheep[full]==2.0a11
1+
blacksheep[full]~=2.0.0
22
uvicorn==0.22.0
33
uvloop; platform_system != "Windows"
44
{%- if cookiecutter.app_settings_library == "essentials-configuration" %}
55
essentials-configuration[full]
66
{%- endif %}
7+
{%- if cookiecutter.app_settings_library == "Pydantic" %}
8+
pydantic-settings
9+
{%- endif %}
710
MarkupSafe==2.1.3
8-
pydantic==1.10.10
11+
pydantic==2.5.2

0 commit comments

Comments
 (0)