Skip to content

Commit f4fd0ff

Browse files
freemindcoreHongbin Huang
andauthored
Releases/0.2.0 (#14)
* feat: Latest Ninja V1 Support (by django-ninja-extra 0.20.0) Updates: "django-ninja-extra >= 0.20.0" "django-ninja-jwt>=5.2.9" * release: v0.2.0 (Ninja V1 Support, mainly Pydantic V2 Upgrade) * fix: update related qa tools - mypy/black etc - to pass codestyle check * fix: mypy check --------- Co-authored-by: Hongbin Huang <[email protected]>
1 parent 39b96b6 commit f4fd0ff

File tree

11 files changed

+24
-22
lines changed

11 files changed

+24
-22
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
args: [--allow-missing-credentials]
2424

2525
- repo: https://github.com/psf/black
26-
rev: 22.8.0
26+
rev: 23.10.1
2727
hooks:
2828
- id: black
2929

easy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Django Easy API - Easy and Fast Django REST framework based on Django-ninja-extra"""
22

3-
__version__ = "0.1.40"
3+
__version__ = "0.2.0"
44

55
from easy.main import EasyAPI
66

easy/controller/auto_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def create_api_controller(
5858
},
5959
)
6060

61-
return api_controller( # type: ignore
61+
return api_controller(
6262
f"/{app_name}/{model_name.lower()}",
6363
tags=[f"{model_name} {controller_name_prefix}API"],
6464
permissions=[permission_class],

easy/controller/meta_conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Optional, Type, Union
1+
from typing import Any, List, Optional, Type, Union
22

33
from django.db import models
44

@@ -24,7 +24,7 @@
2424

2525

2626
class ModelOptions:
27-
def __init__(self, options: Dict = None):
27+
def __init__(self, options: Optional[object] = None):
2828
"""
2929
Configuration reader
3030
"""

easy/decorators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from functools import wraps
22
from types import FunctionType
3-
from typing import Any, Callable
3+
from typing import Any, Callable, Optional
44
from urllib.parse import urlparse
55

66
from django.conf import settings
@@ -11,7 +11,7 @@
1111

1212
def request_passes_test(
1313
test_func: Callable[[Any], Any],
14-
login_url: str = None,
14+
login_url: Optional[str] = None,
1515
redirect_field_name: str = REDIRECT_FIELD_NAME,
1616
) -> Callable[[FunctionType], Callable[[HttpRequest, Any], Any]]:
1717
"""
@@ -45,7 +45,7 @@ def _wrapped_view(request: HttpRequest, *args: Any, **kwargs: Any) -> Any:
4545

4646

4747
def docs_permission_required(
48-
view_func: FunctionType = None,
48+
view_func: Optional[FunctionType] = None,
4949
redirect_field_name: str = REDIRECT_FIELD_NAME,
5050
login_url: str = "admin:login",
5151
) -> Any:

easy/domain/orm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def serialize_many_relationship(
220220
return {}
221221
out = {}
222222
try:
223-
for k, v in obj._prefetched_objects_cache.items(): # type: ignore
223+
for k, v in obj._prefetched_objects_cache.items():
224224
field_name = k if hasattr(obj, k) else k + "_set"
225225
if v:
226226
if self.get_model_join(obj):

easy/exception.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.utils.translation import gettext_lazy as _
12
from ninja_extra import status
23
from ninja_extra.exceptions import APIException
34

@@ -8,7 +9,7 @@ class BaseAPIException(APIException):
89
"""
910

1011
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
11-
default_detail = (
12+
default_detail = _(
1213
"There is an unexpected error, please try again later, if the problem "
1314
"persists, please contact customer support team for further support."
1415
)
@@ -20,4 +21,4 @@ class APIAuthException(BaseAPIException):
2021
"""
2122

2223
status_code = status.HTTP_401_UNAUTHORIZED
23-
default_detail = "Unauthorized"
24+
default_detail = _("Unauthorized")

easy/permissions/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def has_permission(
2121
"""
2222
has_perm: bool = True
2323
if hasattr(controller, "service"):
24-
has_perm = controller.service.check_permission(request, controller) # type: ignore
24+
has_perm = controller.service.check_permission(request, controller)
2525
return has_perm
2626

2727
def has_object_permission(
@@ -32,7 +32,7 @@ def has_object_permission(
3232
"""
3333
has_perm: bool = True
3434
if hasattr(controller, "service"):
35-
has_perm = controller.service.check_object_permission( # type: ignore
35+
has_perm = controller.service.check_object_permission(
3636
request, controller, obj
3737
)
3838
return has_perm

easy/testing/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from json import dumps as json_dumps
2-
from typing import Any, Callable, Dict, List, Sequence, Type, Union, cast
2+
from typing import Any, Callable, Dict, List, Optional, Sequence, Type, Union, cast
33
from unittest.mock import Mock
44
from urllib.parse import urlencode
55

@@ -22,7 +22,7 @@ def __init__(
2222
) -> None:
2323
if hasattr(router_or_app, "get_api_controller"):
2424
api = api_cls(auth=auth)
25-
controller_ninja_api_controller = router_or_app.get_api_controller() # type: ignore
25+
controller_ninja_api_controller = router_or_app.get_api_controller()
2626
assert controller_ninja_api_controller
2727
controller_ninja_api_controller.set_api_instance(api)
2828
self._urls_cache = list(controller_ninja_api_controller.urls_paths(""))
@@ -33,7 +33,7 @@ def request(
3333
self,
3434
method: str,
3535
path: str,
36-
data: Dict = {},
36+
data: Optional[Dict] = None,
3737
json: Any = None,
3838
**request_params: Any,
3939
) -> "NinjaResponse":
@@ -43,7 +43,7 @@ def request(
4343
query = request_params.pop("query")
4444
url_encode = urlencode(query)
4545
path = f"{path}?{url_encode}"
46-
func, request, kwargs = self._resolve(method, path, data, request_params)
46+
func, request, kwargs = self._resolve(method, path, data, request_params) # type: ignore
4747
return self._call(func, request, kwargs) # type: ignore
4848

4949
@property

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ test = [
5757
"pytest-cov",
5858
"pytest-django",
5959
"pytest-asyncio",
60-
"black",
60+
"black==23.10.1",
61+
"mypy==1.6.1",
6162
"isort",
62-
"injector == 0.19.0",
63+
"injector>= 0.19.0",
6364
"flake8",
64-
"mypy==0.931",
6565
"django-stubs",
6666
"factory-boy==3.2.1",
6767
"django_coverage_plugin",
68-
"django-ninja-extra >= 0.16.0",
69-
"django-ninja-jwt>=5.1.0",
68+
"django-ninja-extra >= 0.20.0",
69+
"django-ninja-jwt>=5.2.9",
7070
"Django >= 3.1",
7171
]
7272
dev = [

0 commit comments

Comments
 (0)