Skip to content

Commit 09e7035

Browse files
committed
🔧 Update (libraries): Pydantic 2.8.0, Ruff 0.5.0, SQLAlchemy 2.0.31 and Mypy 1.10.1
1 parent 7d993a3 commit 09e7035

7 files changed

Lines changed: 370 additions & 353 deletions

File tree

‎.pre-commit-config.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
- --keep-runtime-typing
3030

3131
- repo: https://github.com/astral-sh/ruff-pre-commit
32-
rev: v0.4.8
32+
rev: v0.5.0
3333
hooks:
3434
# Run the linter.
3535
- id: ruff
@@ -51,14 +51,14 @@ repos:
5151
args: [ "--config", "pyproject.toml" ]
5252

5353
- repo: https://github.com/astral-sh/ruff-pre-commit
54-
rev: v0.4.8
54+
rev: v0.5.0
5555
hooks:
5656
# Run the formatter.
5757
- id: ruff-format
5858
args: [ "--config", "pyproject.toml" ]
5959

6060
- repo: https://github.com/pre-commit/mirrors-mypy
61-
rev: v1.10.0
61+
rev: v1.10.1
6262
hooks:
6363
- id: mypy
6464
args: [ "--config-file", "pyproject.toml" ]
@@ -71,7 +71,7 @@ repos:
7171
exclude: "introduction/pydantic_intro.py"
7272

7373
- repo: https://github.com/PyCQA/bandit
74-
rev: 1.7.8
74+
rev: 1.7.9
7575
hooks:
7676
- id: bandit
7777
args: [ "-c", "pyproject.toml" ]

‎app/config/init_settings.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def get_image_b64(image_path: str) -> str:
2323
return base64.b64encode(Path(image_path).read_bytes()).decode("utf")
2424

2525

26-
img_b64: str = get_image_b64("assets/images/project.png")
27-
users_b64: str = get_image_b64("assets/images/users.png")
26+
img_b64: str = get_image_b64("./assets/images/project.png")
27+
users_b64: str = get_image_b64("./assets/images/users.png")
2828

2929

3030
class InitSettings(BaseSettings):

‎app/schemas/user.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44

55
from datetime import date
66

7-
from pydantic import BaseModel, ConfigDict, EmailStr, Field, field_validator
7+
from pydantic import (
8+
BaseModel,
9+
ConfigDict,
10+
EmailStr,
11+
Field,
12+
PastDate,
13+
field_validator,
14+
)
815
from pydantic.config import JsonDict
916
from pydantic_extra_types.phone_numbers import (
1017
PhoneNumber as PydanticPhoneNumber,
@@ -49,7 +56,7 @@ class UserBase(BaseModel):
4956
min_length=8,
5057
max_length=14,
5158
)
52-
birthdate: date | None = Field(
59+
birthdate: PastDate | None = Field(
5360
default=None, title="Birthdate", description="Birthday of the User"
5461
)
5562
phone_number: PydanticPhoneNumber | None = Field(

‎introduction/pydantic_intro.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def validate_composed_name(
3939
try:
4040
user: User = User(
4141
name="johndoe",
42-
age="23",
42+
age="hola",
4343
)
44-
print(user.name)
44+
print(user.name, user.age)
4545
except ValidationError as exc:
4646
print(exc)

‎introduction/sa_raw.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from sqlalchemy import CursorResult, Engine, TextClause, create_engine, text
1313

1414
engine: Engine = create_engine(
15-
"postgresql://user:password@server/database",
15+
"postgresql://user:Password123@0.0.0.0:5432/data_science_prd",
1616
)
1717
text_clause: TextClause = text(
1818
"""
@@ -45,6 +45,7 @@
4545
text_clause,
4646
)
4747
data: list[tuple[Any, ...]] = [tuple(row) for row in cursor_result]
48+
# [(1, "A", 54.4,), (2, "ASDA", 0.42, ), (...), (), (), (), (), (), ... ]
4849
for record in data:
4950
print(record)
5051

@@ -63,4 +64,5 @@
6364
for record in data:
6465
writer.writerow(record)
6566

67+
# Another option with Pandas
6668
# dataframe: pd.DataFrame = pd.DataFrame(data, columns=file_header,)

‎poetry.lock‎

Lines changed: 338 additions & 330 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,26 @@ classifiers = [
6363

6464
[tool.poetry.dependencies]
6565
python = "^3.12"
66-
pydantic = "^2.7.3"
67-
pydantic-core = "^2.18.4"
68-
pydantic-settings = "^2.3.1"
69-
pydantic-extra-types = "^2.8.0"
70-
email-validator = "^2.1.1"
71-
phonenumbers = "^8.13.38"
66+
pydantic = "^2.8.0"
67+
pydantic-core = "^2.20.0"
68+
pydantic-settings = "^2.3.4"
69+
pydantic-extra-types = "^2.8.2"
70+
email-validator = "^2.2.0"
71+
phonenumbers = "^8.13.40"
7272
python-dotenv = "^1.0.1"
73-
sqlalchemy = "^2.0.30"
74-
psycopg = {extras = ["binary", "pool"], version = "^3.1.19"}
73+
sqlalchemy = "^2.0.31"
74+
psycopg = {extras = ["binary", "pool"], version = "^3.2.1"}
7575
isort = {extras = ["colors"], version = "^5.13.2"}
7676
black = "^24.4.2"
77-
ruff = "^0.4.8"
78-
mypy = "^1.10.0"
77+
ruff = "^0.5.0"
78+
mypy = "^1.10.1"
7979
pre-commit = "^3.7.1"
8080
fastapi = {extras = ["all"], version = "^0.111.0"}
8181
uvicorn = "^0.30.1"
8282
starlette = "^0.37.2"
8383
requests = "^2.32.3"
84-
types-requests = "^2.32.0.20240602"
85-
urllib3 = "^2.2.1"
84+
types-requests = "^2.32.0.20240622"
85+
urllib3 = "^2.2.2"
8686
jinja2 = "^3.1.4"
8787

8888

0 commit comments

Comments
 (0)