Skip to content

Commit 5850d8b

Browse files
authored
Merge pull request #56 from python-ellar/pydanticv2_upgrade
Pydanticv2 upgrade
2 parents d1d3d40 + 57354c5 commit 5850d8b

File tree

14 files changed

+65
-62
lines changed

14 files changed

+65
-62
lines changed

.github/workflows/test_full.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ jobs:
3737
run: pip install flit
3838
- name: Install Dependencies
3939
run: flit install --symlink
40-
- name: Black
41-
run: black --check ellar_cli tests
4240
- name: Ruff linting check
4341
run: ruff check ellar_cli tests
4442
- name: mypy

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ lint: ## Run code linters
2323
mypy ellar_cli
2424

2525
fmt format: ## Run code formatters
26-
black ellar_cli tests
26+
ruff format ellar_cli tests
2727
ruff check --fix ellar_cli tests
2828

2929
test: ## Run tests

ellar_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Ellar CLI Tool for Scaffolding Ellar Projects, Modules and also running Ellar Commands"""
22

3-
__version__ = "0.2.5"
3+
__version__ = "0.2.7"

ellar_cli/scaffolding/project_template/project_name/config.ellar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export ELLAR_CONFIG_MODULE={{project_name}}.config:DevelopmentConfig
88

99
import typing as t
1010

11-
from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type
11+
from ellar.pydantic import ENCODERS_BY_TYPE as encoders_by_type
1212
from starlette.middleware import Middleware
1313
from ellar.common import IExceptionHandler, JSONResponse
1414
from ellar.core import ConfigDefaultTypesMixin

ellar_cli/scaffolding/project_template/project_name/root_module.ellar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ from ellar.samples.modules import HomeModule
77
class ApplicationModule(ModuleBase):
88
@exception_handler(404)
99
def exception_404_handler(cls, ctx: IExecutionContext, exc: Exception) -> Response:
10-
return JSONResponse(dict(detail="Resource not found."))
10+
return JSONResponse(dict(detail="Resource not found."), status_code=404)

ellar_cli/schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import typing as t
22

33
from ellar.common.serializer import Serializer
4-
from pydantic import Field
4+
from ellar.pydantic import Field
55

66

77
class EllarPyProjectSerializer(Serializer):
@@ -18,9 +18,6 @@ class EllarScaffoldList(Serializer):
1818
files: t.List["EllarScaffoldList"] = Field(default=[])
1919

2020

21-
EllarScaffoldList.update_forward_refs()
22-
23-
2421
class EllarScaffoldSchema(Serializer):
2522
context: t.List[str]
2623
files: t.List[EllarScaffoldList]
@@ -37,3 +34,6 @@ def schema_example(cls) -> "EllarScaffoldSchema":
3734
},
3835
],
3936
)
37+
38+
39+
EllarScaffoldList.model_rebuild()

ellar_cli/service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def _wrap(self: "EllarCLIService", *args: t.Any, **kwargs: t.Any) -> t.Any:
2929
if os.environ.get(ELLAR_CONFIG_MODULE) is None and self.has_meta:
3030
# export ELLAR_CONFIG_MODULE module
3131
os.environ.setdefault(
32-
ELLAR_CONFIG_MODULE, self._meta.config # type:ignore[union-attr]
32+
ELLAR_CONFIG_MODULE,
33+
self._meta.config, # type:ignore[union-attr]
3334
)
3435
return func(self, *args, **kwargs)
3536

mypy.ini

Lines changed: 0 additions & 37 deletions
This file was deleted.

pyproject.toml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies = [
4343
# exclude 0.11.2 and 0.11.3 due to https://github.com/sdispater/tomlkit/issues/225
4444
"tomlkit >=0.11.1,<1.0.0,!=0.11.2,!=0.11.3",
4545
"uvicorn[standard] == 0.23.2",
46-
"ellar >= 0.5.7"
46+
"ellar >= 0.5.8"
4747
]
4848

4949
[project.scripts]
@@ -58,10 +58,8 @@ Homepage = "https://eadwincode.github.io/ellar-cli/"
5858
test = [
5959
"pytest >=7.1.3,<8.0.0",
6060
"pytest-cov >=2.12.0,<5.0.0",
61-
"ruff ==0.1.6",
6261
"mypy == 1.7.1",
6362
"ruff ==0.1.7",
64-
"black ==23.11.0",
6563
"pytest-asyncio",
6664
"autoflake",
6765
]
@@ -89,3 +87,46 @@ ignore = [
8987

9088
[tool.ruff.isort]
9189
known-third-party = ["ellar",]
90+
91+
[tool.mypy]
92+
93+
show_column_numbers = true
94+
95+
follow_imports = 'normal'
96+
ignore_missing_imports = true
97+
98+
# be strict
99+
disallow_untyped_calls = true
100+
warn_return_any = true
101+
strict_optional = true
102+
warn_no_return = true
103+
warn_redundant_casts = true
104+
warn_unused_ignores = true
105+
106+
disallow_untyped_defs = true
107+
check_untyped_defs = true
108+
implicit_reexport = false
109+
110+
[[tool.mypy.overrides]]
111+
module = "ellar_cli.compatible.*"
112+
ignore_errors = true
113+
114+
[[tool.mypy.overrides]]
115+
module = "ellar_cli.cli.*"
116+
ignore_errors = true
117+
118+
[[tool.mypy.overrides]]
119+
module = "ellar_cli.schema.*"
120+
ignore_errors = true
121+
122+
[[tool.mypy.overrides]]
123+
module = "ellar_cli.__main__.*"
124+
ignore_errors = true
125+
126+
[[tool.mypy.overrides]]
127+
module = "ellar_cli.manage_commands.*"
128+
ignore_errors = true
129+
130+
[[tool.mypy.overrides]]
131+
module = "ellar_cli.testing.*"
132+
ignore_errors = true

tests/sample_app/example_project/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ellar.common import JSONResponse
1212
from ellar.core import ConfigDefaultTypesMixin
1313
from ellar.core.versioning import BaseAPIVersioning, DefaultAPIVersioning
14-
from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type
14+
from ellar.pydantic import ENCODERS_BY_TYPE as encoders_by_type
1515
from starlette.middleware import Middleware
1616

1717

0 commit comments

Comments
 (0)