Skip to content

Commit cc89616

Browse files
committed
Merge branch 'release/3.3.9'
2 parents bcf1389 + cc331c1 commit cc89616

File tree

10 files changed

+396
-273
lines changed

10 files changed

+396
-273
lines changed

fastapi_template/input_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ class Database(BaseModel):
5252
),
5353
DatabaseType.postgresql: Database(
5454
name=DatabaseType.postgresql.value,
55-
image="postgres:13.6-bullseye",
55+
image="postgres:13.8-bullseye",
5656
async_driver="postgresql+asyncpg",
5757
driver_short="postgres",
5858
driver="postgresql",
5959
port=5432,
6060
),
6161
DatabaseType.mysql: Database(
6262
name=DatabaseType.mysql.value,
63-
image="bitnami/mysql:8.0.28",
63+
image="bitnami/mysql:8.0.30",
6464
async_driver="mysql+aiomysql",
6565
driver_short="mysql",
6666
driver="mysql",

fastapi_template/template/{{cookiecutter.project_name}}/.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ ignore =
6868
DJ11,
6969
; Found mutable module constant.
7070
WPS407,
71+
; Found too many empty lines in `def`
72+
WPS473,
7173

7274
per-file-ignores =
7375
; all tests

fastapi_template/template/{{cookiecutter.project_name}}/.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ jobs:
6262
POSTGRES_DB: {{ cookiecutter.project_name }}
6363
{%- endif %}
6464
{%- if cookiecutter.db_info.name == "mysql" %}
65-
MYSQL_PASSWORD: {{ cookiecutter.project_name }}
66-
MYSQL_USER: {{ cookiecutter.project_name }}
67-
MYSQL_DATABASE: {{ cookiecutter.project_name }}
68-
ALLOW_EMPTY_PASSWORD: yes
65+
MYSQL_ROOT_PASSWORD: "{{ cookiecutter.project_name }}"
66+
MYSQL_ROOT_USER: "{{ cookiecutter.project_name }}"
67+
MYSQL_DATABASE: "{{ cookiecutter.project_name }}"
68+
MYSQL_AUTHENTICATION_PLUGIN: "mysql_native_password"
6969
{%- endif %}
7070
{%- if cookiecutter.db_info.name == "mysql" %}
7171
options: >-
7272
--health-cmd="mysqladmin ping -u root"
7373
--health-interval=15s
7474
--health-timeout=5s
75-
--health-retries=5
75+
--health-retries=6
7676
{%- endif %}
7777
{%- if cookiecutter.db_info.name == "postgresql" %}
7878
options: >-

fastapi_template/template/{{cookiecutter.project_name}}/deploy/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ RUN apt-get update && apt-get install -y \
77
&& rm -rf /var/lib/apt/lists/*
88
{%- endif %}
99

10+
11+
{%- if cookiecutter.db_info.name == "postgresql" %}
12+
RUN apt-get update && apt-get install -y \
13+
gcc \
14+
&& rm -rf /var/lib/apt/lists/*
15+
{%- endif %}
16+
17+
1018
RUN pip install poetry==1.1.13
1119

1220
# Configuring poetry
@@ -19,7 +27,7 @@ WORKDIR /app/src
1927
# Installing requirements
2028
RUN poetry install
2129

22-
{%- if cookiecutter.db_info.name == "mysql" %}
30+
{%- if cookiecutter.db_info.name == "mysql" or cookiecutter.db_info.name == "postgresql" %}
2331
# Removing gcc
2432
RUN apt-get purge -y \
2533
gcc \

fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,105 +12,105 @@ readme = "README.md"
1212

1313
[tool.poetry.dependencies]
1414
python = "^3.9"
15-
fastapi = "^0.75.0"
16-
uvicorn = { version = "^0.17.0", extras = ["standard"] }
17-
pydantic = {version = "^1.9.0", extras = ["dotenv"]}
18-
yarl = "^1.7.2"
19-
ujson = "^5.1.0"
15+
fastapi = "^0.85.0"
16+
uvicorn = { version = "^0.18.3", extras = ["standard"] }
17+
pydantic = {version = "^1.10.2", extras = ["dotenv"]}
18+
yarl = "^1.8.1"
19+
ujson = "^5.5.0"
2020
{%- if cookiecutter.orm == "piccolo" %}
2121
{%- if cookiecutter.db_info.name == "postgresql" %}
22-
piccolo = {version = "^0.74.0", extras = ["postgres"]}
22+
piccolo = {version = "^0.91.0", extras = ["postgres"]}
2323
{%- elif cookiecutter.db_info.name == "sqlite" %}
24-
piccolo = {version = "^0.74.0", extras = ["sqlite"]}
24+
piccolo = {version = "^0.91.0", extras = ["sqlite"]}
2525
{%- endif %}
2626
{%- endif %}
2727
{%- if cookiecutter.orm == "sqlalchemy" %}
28-
SQLAlchemy = {version = "^1.4", extras = ["mypy", "asyncio"]}
28+
SQLAlchemy = {version = "^1.4.41", extras = ["mypy", "asyncio"]}
2929
{%- if cookiecutter.enable_migrations == "True" %}
30-
alembic = "^1.7.7"
30+
alembic = "^1.8.1"
3131
{%- endif %}
3232
{%- if cookiecutter.db_info.name == "postgresql" %}
33-
asyncpg = {version = "^0.25.0", extras = ["sa"]}
33+
asyncpg = {version = "^0.26.0", extras = ["sa"]}
3434
{%- elif cookiecutter.db_info.name == "sqlite" %}
3535
aiosqlite = "^0.17.0"
3636
{%- elif cookiecutter.db_info.name == "mysql" %}
37-
aiomysql = "^0.0.22"
38-
mysqlclient = "^2.1.0"
37+
aiomysql = "^0.1.1"
38+
mysqlclient = "^2.1.1"
3939
{%- endif %}
4040
{%- endif %}
4141
{%- if cookiecutter.orm == "tortoise" %}
42-
tortoise-orm = "^0.19.0"
42+
tortoise-orm = "^0.19.2"
4343
{%- if cookiecutter.enable_migrations == "True" %}
44-
aerich = "^0.6.2"
44+
aerich = "^0.7.1"
4545
{%- endif %}
4646
{%- if cookiecutter.db_info.name == "postgresql" %}
47-
asyncpg = "^0.25.0"
47+
asyncpg = "^0.26.0"
4848
{%- elif cookiecutter.db_info.name == "sqlite" %}
4949
aiosqlite = "^0.17.0"
5050
{%- elif cookiecutter.db_info.name == "mysql" %}
51-
aiomysql = "^0.0.21"
52-
mysqlclient = "^2.0.3"
53-
cryptography = "^36.0.2"
51+
aiomysql = "^0.1.1"
52+
mysqlclient = "^2.1.1"
53+
cryptography = "^38.0.1"
5454
{%- endif %}
5555
{%- endif %}
5656
{%- if cookiecutter.orm == "ormar" %}
57-
ormar = "^0.11.0"
57+
ormar = "^0.11.3"
5858
{%- if cookiecutter.enable_migrations == "True" %}
59-
alembic = "^1.7.7"
59+
alembic = "^1.8.1"
6060
{%- endif %}
6161
{%- if cookiecutter.db_info.name == "postgresql" %}
62-
asyncpg = "^0.25.0"
62+
asyncpg = "^0.26.0"
6363
psycopg2-binary = "^2.9.3"
6464
{%- elif cookiecutter.db_info.name == "sqlite" %}
6565
aiosqlite = "^0.17.0"
6666
{%- elif cookiecutter.db_info.name == "mysql" %}
67-
aiomysql = "^0.0.22"
68-
mysqlclient = "^2.1.0"
67+
aiomysql = "^0.1.1"
68+
mysqlclient = "^2.1.1"
6969
{%- endif %}
7070
{%- endif %}
7171
{%- if cookiecutter.enable_redis == "True" %}
72-
redis = {version = "^4.3.3", extras = ["hiredis"]}
72+
redis = {version = "^4.3.4", extras = ["hiredis"]}
7373
{%- endif %}
7474
{%- if cookiecutter.self_hosted_swagger == 'True' %}
75-
aiofiles = "^0.8.0"
75+
aiofiles = "^22.1.0"
7676
{%- endif %}
7777
{%- if cookiecutter.orm == "psycopg" %}
78-
psycopg = { version = "^3.0.11", extras = ["binary", "pool"] }
78+
psycopg = { version = "^3.1.2", extras = ["binary", "pool"] }
7979
{%- endif %}
80-
httptools = "^0.3.0"
80+
httptools = "^0.5.0"
8181
{%- if cookiecutter.api_type == "graphql" %}
82-
strawberry-graphql = { version = "^0.114.2", extras = ["fastapi"] }
82+
strawberry-graphql = { version = "^0.133.2", extras = ["fastapi"] }
8383
{%- endif %}
8484
{%- if cookiecutter.enable_rmq == "True" %}
85-
aio-pika = "^7.2.0"
85+
aio-pika = "^8.2.3"
8686
{%- endif %}
8787
{%- if cookiecutter.prometheus_enabled == "True" %}
8888
prometheus-client = "^0.14.1"
89-
prometheus-fastapi-instrumentator = "5.8.1"
89+
prometheus-fastapi-instrumentator = "5.9.1"
9090
{%- endif %}
9191
{%- if cookiecutter.sentry_enabled == "True" %}
92-
sentry-sdk = "^1.5.12"
92+
sentry-sdk = "^1.9.9"
9393
{%- endif %}
9494
{%- if cookiecutter.otlp_enabled == "True" %}
95-
opentelemetry-api = {version = "^1.12.0rc2", allow-prereleases = true}
96-
opentelemetry-sdk = {version = "^1.12.0rc2", allow-prereleases = true}
97-
opentelemetry-exporter-otlp = {version = "^1.12.0rc2", allow-prereleases = true}
98-
opentelemetry-instrumentation = "^0.32b0"
99-
opentelemetry-instrumentation-fastapi = "^0.32b0"
95+
opentelemetry-api = "^1.13.0"
96+
opentelemetry-sdk = "^1.13.0"
97+
opentelemetry-exporter-otlp = "^1.13.0"
98+
opentelemetry-instrumentation = "^0.34b0"
99+
opentelemetry-instrumentation-fastapi = "^0.34b0"
100100
{%- if cookiecutter.enable_loguru != "True" %}
101-
opentelemetry-instrumentation-logging = "^0.32b0"
101+
opentelemetry-instrumentation-logging = "^0.34b0"
102102
{%- endif %}
103103
{%- if cookiecutter.enable_redis == "True" %}
104-
opentelemetry-instrumentation-redis = "^0.32b0"
104+
opentelemetry-instrumentation-redis = "^0.34b0"
105105
{%- endif %}
106106
{%- if cookiecutter.db_info.name == "postgresql" and cookiecutter.orm in ["ormar", "tortoise"] %}
107-
opentelemetry-instrumentation-asyncpg = "^0.32b0"
107+
opentelemetry-instrumentation-asyncpg = "^0.34b0"
108108
{%- endif %}
109109
{%- if cookiecutter.orm == "sqlalchemy" %}
110-
opentelemetry-instrumentation-sqlalchemy = "^0.32b0"
110+
opentelemetry-instrumentation-sqlalchemy = "^0.34b0"
111111
{%- endif %}
112112
{%- if cookiecutter.enable_rmq == "True" %}
113-
opentelemetry-instrumentation-aio-pika = "^0.32b0"
113+
opentelemetry-instrumentation-aio-pika = "^0.34b0"
114114
{%- endif %}
115115
{%- endif %}
116116
{%- if cookiecutter.enable_loguru == "True" %}
@@ -121,29 +121,29 @@ aiokafka = "^0.7.2"
121121
{%- endif %}
122122

123123
[tool.poetry.dev-dependencies]
124-
pytest = "^7.0"
125-
flake8 = "^4.0.1"
126-
mypy = "^0.961"
124+
pytest = "^7.1.3"
125+
flake8 = "~4.0.1"
126+
mypy = "^0.981"
127127
isort = "^5.10.1"
128-
yesqa = "^1.3.0"
129-
pre-commit = "^2.19.0"
130-
wemake-python-styleguide = "^0.16.1"
131-
black = "^22.3.0"
132-
autoflake = "^1.4"
128+
yesqa = "^1.4.0"
129+
pre-commit = "^2.20.0"
130+
wemake-python-styleguide = "^0.17.0"
131+
black = "^22.8.0"
132+
autoflake = "^1.6.1"
133133
{%- if cookiecutter.orm == "sqlalchemy" %}
134-
SQLAlchemy = {version = "^1.4", extras = ["mypy"]}
134+
SQLAlchemy = {version = "^1.4.41", extras = ["mypy"]}
135135
{%- endif %}
136-
pytest-cov = "^3.0.0"
136+
pytest-cov = "^4.0.0"
137137
anyio = "^3.6.1"
138138
pytest-env = "^0.6.2"
139139
{%- if cookiecutter.enable_redis == "True" %}
140-
fakeredis = "^1.8.1"
140+
fakeredis = "^1.9.3"
141141
{%- endif %}
142142
{%- if cookiecutter.orm == "tortoise" %}
143143
asynctest = "^0.13.0"
144-
nest-asyncio = "^1.5.5"
144+
nest-asyncio = "^1.5.6"
145145
{%- endif %}
146-
httpx = "^0.22.0"
146+
httpx = "^0.23.0"
147147

148148
[tool.isort]
149149
profile = "black"

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/application.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
{%- if cookiecutter.sentry_enabled == "True" %}
1818
import sentry_sdk
19-
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
2019
from sentry_sdk.integrations.logging import LoggingIntegration
20+
from sentry_sdk.integrations.fastapi import FastApiIntegration
2121
{%- if cookiecutter.orm == "sqlalchemy" %}
2222
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
2323
{%- endif %}
@@ -47,6 +47,27 @@ def get_app() -> FastAPI:
4747
{%- if cookiecutter.enable_loguru == "True" %}
4848
configure_logging()
4949
{%- endif %}
50+
{%- if cookiecutter.sentry_enabled == "True" %}
51+
if settings.sentry_dsn:
52+
# Enables sentry integration.
53+
sentry_sdk.init(
54+
dsn=settings.sentry_dsn,
55+
traces_sample_rate=settings.sentry_sample_rate,
56+
environment=settings.environment,
57+
integrations=[
58+
FastApiIntegration(transaction_style="endpoint"),
59+
LoggingIntegration(
60+
level=logging.getLevelName(
61+
settings.log_level.value,
62+
),
63+
event_level=logging.ERROR,
64+
),
65+
{%- if cookiecutter.orm == "sqlalchemy" %}
66+
SqlalchemyIntegration(),
67+
{%- endif %}
68+
],
69+
)
70+
{%- endif %}
5071
app = FastAPI(
5172
title="{{cookiecutter.project_name}}",
5273
description="{{cookiecutter.project_description}}",
@@ -95,26 +116,4 @@ def get_app() -> FastAPI:
95116
)
96117
{%- endif %}
97118

98-
{%- if cookiecutter.sentry_enabled == "True" %}
99-
if settings.sentry_dsn:
100-
# Enables sentry integration.
101-
sentry_sdk.init(
102-
dsn=settings.sentry_dsn,
103-
traces_sample_rate=settings.sentry_sample_rate,
104-
environment=settings.environment,
105-
integrations=[
106-
LoggingIntegration(
107-
level=logging.getLevelName(
108-
settings.log_level.value,
109-
),
110-
event_level=logging.ERROR,
111-
),
112-
{%- if cookiecutter.orm == "sqlalchemy" %}
113-
SqlalchemyIntegration(),
114-
{%- endif %}
115-
],
116-
)
117-
app = SentryAsgiMiddleware(app) # type: ignore
118-
{%- endif %}
119-
120119
return app

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/lifetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async def _create_tables() -> None: # pragma: no cover
136136
{%- if cookiecutter.otlp_enabled == "True" %}
137137
def setup_opentelemetry(app: FastAPI) -> None: # pragma: no cover
138138
"""
139-
Enables opentelemetry instrumetnation.
139+
Enables opentelemetry instrumentation.
140140
141141
:param app: current application.
142142
"""

0 commit comments

Comments
 (0)