Skip to content

Commit 4605995

Browse files
authored
Dependencies updated. Fixed issues with new versions. (#177)
1 parent d27b91d commit 4605995

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+877
-756
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
git config --global user.name "fastapi_template"
4141
git config --global user.email "[email protected]"
4242
- name: Run tests
43-
run: poetry run pytest -vv --exitfirst -n auto
43+
run: poetry run pytest -vv

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9.17-alpine
1+
FROM python:3.11.4-slim-bullseye
22

33
RUN apk add --no-cache \
44
curl \
@@ -11,7 +11,8 @@ RUN apk add --no-cache \
1111
# For psycopg \
1212
postgresql-dev \
1313
# For mysql deps \
14-
mariadb-connector-c-dev \
14+
default-libmysqlclient-dev \
15+
pkg-config \
1516
# For UI \
1617
ncurses \
1718
bash

fastapi_template/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pathlib import Path
22

3-
from cookiecutter.exceptions import FailedHookException, OutputDirExistsException
3+
from cookiecutter.exceptions import (FailedHookException,
4+
OutputDirExistsException)
45
from cookiecutter.main import cookiecutter
56
from termcolor import cprint
67

fastapi_template/cli.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1+
import re
12
import shutil
2-
from fastapi_template.input_model import (
3-
BuilderContext,
4-
MenuEntry,
5-
SingularMenuModel,
6-
MultiselectMenuModel,
7-
BaseMenuModel,
8-
Database,
9-
SKIP_ENTRY,
10-
)
113
from importlib.metadata import version
12-
from typing import Callable, List, Optional
13-
from click import Command, Option
14-
import re
4+
from typing import Any, Callable, List, Optional
155

6+
from click import Command, Option
167
from prompt_toolkit import prompt
178
from prompt_toolkit.document import Document
189
from prompt_toolkit.validation import ValidationError, Validator
19-
from typing import Any
2010
from termcolor import colored
2111

12+
from fastapi_template.input_model import (SKIP_ENTRY, BaseMenuModel,
13+
BuilderContext, Database, MenuEntry,
14+
MultiselectMenuModel,
15+
SingularMenuModel)
16+
2217

2318
class SnakeCaseValidator(Validator):
2419
def validate(self, document: Document):
@@ -81,6 +76,7 @@ def checker(ctx: BuilderContext) -> bool:
8176
MenuEntry(
8277
code="graphql",
8378
user_view="GrapQL API",
79+
pydantic_v1=True,
8480
description=(
8581
"Choose this option if you want to create a service with {name}.\n"
8682
"It's more suitable for services with {reason} and deep nesting.".format(
@@ -245,6 +241,7 @@ def checker(ctx: BuilderContext) -> bool:
245241
MenuEntry(
246242
code="ormar",
247243
user_view="Ormar",
244+
pydantic_v1=True,
248245
description=(
249246
"{what} is a great {feature} ORM.\n"
250247
"It's compatible with pydantic models and alembic migrator.".format(
@@ -290,6 +287,7 @@ def checker(ctx: BuilderContext) -> bool:
290287
MenuEntry(
291288
code="piccolo",
292289
user_view="Piccolo",
290+
pydantic_v1=True,
293291
is_hidden=check_db(["postgresql", "sqlite"]),
294292
description=(
295293
"{what} is a great ORM for Postgresql and SQLite.\n"

fastapi_template/input_model.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import abc
12
import enum
2-
from typing import List, Optional, Callable, Any
3+
from collections import UserDict
4+
from typing import Any, Callable, List, Optional
35

4-
from pydantic import BaseModel
56
import click
6-
import abc
7-
from collections import UserDict
87
from prompt_toolkit.shortcuts import checkboxlist_dialog, radiolist_dialog
8+
from pydantic import BaseModel
99

1010
try:
1111
from simple_term_menu import TerminalMenu
@@ -15,20 +15,21 @@
1515

1616
class Database(BaseModel):
1717
name: str
18-
image: Optional[str]
19-
driver: Optional[str]
20-
async_driver: Optional[str]
21-
port: Optional[int]
22-
driver_short: Optional[str]
18+
image: Optional[str] = None
19+
driver: Optional[str] = None
20+
async_driver: Optional[str] = None
21+
port: Optional[int] = None
22+
driver_short: Optional[str] = None
2323

2424

2525
class MenuEntry(BaseModel):
2626
code: str
27-
cli_name: Optional[str]
27+
cli_name: Optional[str] = None
2828
user_view: str
2929
description: str
30-
is_hidden: Optional[Callable[["BuilderContext"], bool]]
31-
additional_info: Any
30+
is_hidden: Optional[Callable[["BuilderContext"], bool]] = None
31+
additional_info: Any = None
32+
pydantic_v1: bool = False
3233

3334
@property
3435
def generated_name(self) -> str:
@@ -83,13 +84,13 @@ def after_ask(self, context: "BuilderContext") -> "BuilderContext":
8384

8485
class SingularMenuModel(BaseMenuModel):
8586
code: str
86-
cli_name: Optional[str]
87+
cli_name: Optional[str] = None
8788
description: str
88-
before_ask_fun: Optional[Callable[["BuilderContext"], Optional[MenuEntry]]]
89+
before_ask_fun: Optional[Callable[["BuilderContext"], Optional[MenuEntry]]] = None
8990
after_ask_fun: Optional[
9091
Callable[["BuilderContext", "SingularMenuModel"], "BuilderContext"]
91-
]
92-
parser: Optional[Callable[[str], Any]]
92+
] = None
93+
parser: Optional[Callable[[str], Any]] = None
9394

9495
def get_cli_options(self) -> List[click.Option]:
9596
cli_name = self.code
@@ -158,6 +159,8 @@ def ask(self, context: "BuilderContext") -> Optional["BuilderContext"]:
158159
return
159160

160161
setattr(context, self.code, chosen_entry.code)
162+
if chosen_entry.pydantic_v1:
163+
context.pydanticv1 = True
161164

162165
return context
163166

@@ -236,6 +239,10 @@ def ask(self, context: "BuilderContext") -> Optional["BuilderContext"]:
236239

237240
for entry in chosen_entries:
238241
setattr(context, entry.code, True)
242+
243+
for ch_entry in chosen_entries:
244+
if ch_entry.pydantic_v1:
245+
context.pydanticv1 = True
239246

240247
return context
241248

fastapi_template/template/cookiecutter.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
"otlp_enabled": {
6060
"type": "bool"
6161
},
62+
"pydanticv1": {
63+
"type": "bool"
64+
},
6265
"_extensions": [
6366
"cookiecutter.extensions.RandomStringExtension"
6467
],

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ ignore =
7070
WPS407,
7171
; Found too many empty lines in `def`
7272
WPS473,
73+
; too many no-cover comments.
74+
WPS403,
7375

7476
per-file-ignores =
7577
; all tests

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
FROM python:3.9.6-slim-buster as prod
1+
FROM python:3.11.4-slim-bullseye as prod
22

33
{%- if cookiecutter.db_info.name == "mysql" %}
44
RUN apt-get update && apt-get install -y \
55
default-libmysqlclient-dev \
66
gcc \
7+
pkg-config \
78
&& rm -rf /var/lib/apt/lists/*
89
{%- endif %}
910

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

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,112 +12,117 @@ readme = "README.md"
1212

1313
[tool.poetry.dependencies]
1414
python = "^3.9"
15-
fastapi = "^0.89.1"
16-
uvicorn = { version = "^0.20.0", extras = ["standard"] }
17-
pydantic = {version = "^1.10.4", extras = ["dotenv"]}
18-
yarl = "^1.8.2"
19-
ujson = "^5.7.0"
15+
fastapi = "^0.100.0"
16+
uvicorn = { version = "^0.22.0", extras = ["standard"] }
17+
{%- if cookiecutter.pydanticv1 == "True" %}
18+
pydantic = { version = "^1", extras=["dotenv"] }
19+
{%- else %}
20+
pydantic = "^2"
21+
pydantic-settings = "^2"
22+
{%- endif %}
23+
yarl = "^1.9.2"
24+
ujson = "^5.8.0"
2025
{%- if cookiecutter.orm == "piccolo" %}
2126
{%- if cookiecutter.db_info.name == "postgresql" %}
22-
piccolo = {version = "^0.105.0", extras = ["postgres"]}
27+
piccolo = {version = "^0.117.0", extras = ["postgres"]}
2328
{%- elif cookiecutter.db_info.name == "sqlite" %}
24-
piccolo = {version = "^0.105.0", extras = ["sqlite"]}
29+
piccolo = {version = "^0.117.0", extras = ["sqlite"]}
2530
{%- endif %}
2631
{%- endif %}
2732
{%- if cookiecutter.orm == "sqlalchemy" %}
28-
SQLAlchemy = {version = "^2.0.0", extras = ["asyncio"]}
33+
SQLAlchemy = {version = "^2.0.18", extras = ["asyncio"]}
2934
{%- if cookiecutter.enable_migrations == "True" %}
30-
alembic = "^1.9.2"
35+
alembic = "^1.11.1"
3136
{%- endif %}
3237
{%- if cookiecutter.db_info.name == "postgresql" %}
33-
asyncpg = {version = "^0.27.0", extras = ["sa"]}
38+
asyncpg = {version = "^0.28.0", extras = ["sa"]}
3439
{%- elif cookiecutter.db_info.name == "sqlite" %}
35-
aiosqlite = "^0.18.0"
40+
aiosqlite = "^0.19.0"
3641
{%- elif cookiecutter.db_info.name == "mysql" %}
37-
aiomysql = "^0.1.1"
38-
mysqlclient = "^2.1.1"
42+
aiomysql = "^0.2.0"
43+
mysqlclient = "^2.2.0"
3944
{%- endif %}
4045
{%- endif %}
4146
{%- if cookiecutter.orm == "tortoise" %}
42-
tortoise-orm = "^0.19.2"
47+
tortoise-orm = "^0.19.3"
4348
{%- if cookiecutter.enable_migrations == "True" %}
4449
aerich = "^0.7.1"
4550
{%- endif %}
4651
{%- if cookiecutter.db_info.name == "postgresql" %}
47-
asyncpg = "^0.27.0"
52+
asyncpg = "^0.28.0"
4853
{%- elif cookiecutter.db_info.name == "sqlite" %}
49-
aiosqlite = "<0.18.0"
54+
aiosqlite = "<0.19.0"
5055
{%- elif cookiecutter.db_info.name == "mysql" %}
51-
aiomysql = "^0.1.1"
52-
mysqlclient = "^2.1.1"
53-
cryptography = "^39.0.0"
56+
aiomysql = "^0.2.0"
57+
mysqlclient = "^2.2.0"
58+
cryptography = "^41.0.1"
5459
{%- endif %}
5560
{%- endif %}
5661
{%- if cookiecutter.orm == "ormar" %}
57-
ormar = "^0.12.0"
62+
ormar = "^0.12.2"
5863
{%- if cookiecutter.enable_migrations == "True" %}
59-
alembic = "^1.9.2"
64+
alembic = "^1.11.1"
6065
{%- endif %}
6166
{%- if cookiecutter.db_info.name == "postgresql" %}
62-
asyncpg = "^0.27.0"
63-
psycopg2-binary = "^2.9.5"
67+
asyncpg = "^0.28.0"
68+
psycopg2-binary = "^2.9.6"
6469
{%- elif cookiecutter.db_info.name == "sqlite" %}
65-
aiosqlite = "^0.18.0"
70+
aiosqlite = "^0.19.0"
6671
{%- elif cookiecutter.db_info.name == "mysql" %}
67-
aiomysql = "^0.1.1"
68-
mysqlclient = "^2.1.1"
72+
aiomysql = "^0.2.0"
73+
mysqlclient = "^2.2.0"
6974
{%- endif %}
7075
{%- endif %}
7176
{%- if cookiecutter.enable_redis == "True" %}
72-
redis = {version = "^4.4.2", extras = ["hiredis"]}
77+
redis = {version = "^4.6.0", extras = ["hiredis"]}
7378
{%- endif %}
7479
{%- if cookiecutter.self_hosted_swagger == 'True' %}
75-
aiofiles = "^22.1.0"
80+
aiofiles = "^23.1.0"
7681
{%- endif %}
7782
{%- if cookiecutter.orm == "psycopg" %}
78-
psycopg = { version = "^3.1.8", extras = ["binary", "pool"] }
83+
psycopg = { version = "^3.1.9", extras = ["binary", "pool"] }
7984
{%- endif %}
80-
httptools = "^0.5.0"
85+
httptools = "^0.6.0"
8186
{%- if cookiecutter.api_type == "graphql" %}
82-
strawberry-graphql = { version = "^0.155.2", extras = ["fastapi"] }
87+
strawberry-graphql = { version = "^0.194.4", extras = ["fastapi"] }
8388
{%- endif %}
8489
{%- if cookiecutter.enable_rmq == "True" %}
85-
aio-pika = "^8.3.0"
90+
aio-pika = "^9.1.4"
8691
{%- endif %}
8792
{%- if cookiecutter.prometheus_enabled == "True" %}
88-
prometheus-client = "^0.16.0"
89-
prometheus-fastapi-instrumentator = "5.9.1"
93+
prometheus-client = "^0.17.0"
94+
prometheus-fastapi-instrumentator = "6.0.0"
9095
{%- endif %}
9196
{%- if cookiecutter.sentry_enabled == "True" %}
92-
sentry-sdk = "^1.14.0"
97+
sentry-sdk = "^1.27.1"
9398
{%- endif %}
9499
{%- if cookiecutter.otlp_enabled == "True" %}
95-
opentelemetry-api = "^1.15.0"
96-
opentelemetry-sdk = "^1.15.0"
97-
opentelemetry-exporter-otlp = "^1.15.0"
98-
opentelemetry-instrumentation = "^0.36b0"
99-
opentelemetry-instrumentation-fastapi = "^0.36b0"
100+
opentelemetry-api = "^1.18.0"
101+
opentelemetry-sdk = "^1.18.0"
102+
opentelemetry-exporter-otlp = "^1.18.0"
103+
opentelemetry-instrumentation = "^0.39b0"
104+
opentelemetry-instrumentation-fastapi = "^0.39b0"
100105
{%- if cookiecutter.enable_loguru != "True" %}
101-
opentelemetry-instrumentation-logging = "^0.36b0"
106+
opentelemetry-instrumentation-logging = "^0.39b0"
102107
{%- endif %}
103108
{%- if cookiecutter.enable_redis == "True" %}
104-
opentelemetry-instrumentation-redis = "^0.36b0"
109+
opentelemetry-instrumentation-redis = "^0.39b0"
105110
{%- endif %}
106111
{%- if cookiecutter.db_info.name == "postgresql" and cookiecutter.orm in ["ormar", "tortoise"] %}
107-
opentelemetry-instrumentation-asyncpg = "^0.36b0"
112+
opentelemetry-instrumentation-asyncpg = "^0.39b0"
108113
{%- endif %}
109114
{%- if cookiecutter.orm == "sqlalchemy" %}
110-
opentelemetry-instrumentation-sqlalchemy = "^0.36b0"
115+
opentelemetry-instrumentation-sqlalchemy = "^0.39b0"
111116
{%- endif %}
112117
{%- if cookiecutter.enable_rmq == "True" %}
113-
opentelemetry-instrumentation-aio-pika = "^0.36b0"
118+
opentelemetry-instrumentation-aio-pika = "^0.39b0"
114119
{%- endif %}
115120
{%- endif %}
116121
{%- if cookiecutter.enable_loguru == "True" %}
117-
loguru = "^0.6.0"
122+
loguru = "^0.7.0"
118123
{%- endif %}
119124
{%- if cookiecutter.enable_kafka == "True" %}
120-
aiokafka = "^0.8.0"
125+
aiokafka = "^0.8.1"
121126
{%- endif %}
122127
{%- if cookiecutter.enable_taskiq == "True" %}
123128
taskiq = "^0"
@@ -132,7 +137,7 @@ taskiq-aio-pika = "^0"
132137
{%- endif %}
133138

134139
{%- if (cookiecutter.enable_rmq or cookiecutter.enable_rmq) != "True" %}
135-
pyzmq = "^25.0.2"
140+
pyzmq = "^25"
136141
{%- endif %}
137142

138143
{%- endif %}
@@ -179,6 +184,9 @@ allow_untyped_decorators = true
179184
warn_unused_ignores = false
180185
warn_return_any = false
181186
namespace_packages = true
187+
{%- if cookiecutter.api_type == "graphql" %}
188+
plugins = ["strawberry.ext.mypy_plugin"]
189+
{%- endif %}
182190

183191
{%- if cookiecutter.enable_redis == "True" %}
184192

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/__main__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import uvicorn
21
import os
32
import shutil
43

4+
import uvicorn
55
from {{cookiecutter.project_name}}.settings import settings
66

7-
87
{%- if cookiecutter.prometheus_enabled == "True" %}
98
def set_multiproc_dir() -> None:
109
"""

0 commit comments

Comments
 (0)