Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropped Black #102

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ jobs:
run: pip install flit
- name: Install Dependencies
run: flit install --symlink
- name: Black
run: black --check ninja_extra tests
- name: Ruff Linting Check
run: ruff check ninja_extra tests
- name: mypy
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,25 @@ clean: ## Removing cached python compiled files
find . -name \*pyo | xargs rm -fv
find . -name \*~ | xargs rm -fv
find . -name __pycache__ | xargs rm -rfv
find . -name .ruff_cache | xargs rm -rfv

install:clean ## Install dependencies
flit install --deps develop --symlink
pre-commit install -f

lint:fmt ## Run code linters
make clean
black --check ninja_extra tests
ruff check ninja_extra tests
mypy ninja_extra

fmt format:clean ## Run code formatters
black ninja_extra tests
ruff format ninja_extra tests
ruff check --fix ninja_extra tests


test:clean ## Run tests
pytest .

test-cov:clean ## Run tests with coverage
make clean
pytest --cov=ninja_extra --cov-report term-missing tests

doc-deploy:clean ## Run Deploy Documentation
Expand Down
2 changes: 1 addition & 1 deletion ninja_extra/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_route_functions(cls: Type) -> Iterable[RouteFunction]:


def get_all_controller_route_function(
controller: Union[Type["ControllerBase"], Type]
controller: Union[Type["ControllerBase"], Type],
) -> List[RouteFunction]: # pragma: no cover
route_functions: List[RouteFunction] = []
for item in dir(controller):
Expand Down
4 changes: 1 addition & 3 deletions ninja_extra/controllers/model/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,7 @@ def list_items(self: "ModelControllerBase", **kwargs: t.Any) -> t.Any:
list_items = route.get(
working_path,
response={
status_code: pagination_response_schema[
schema_out
] # type:ignore[index]
status_code: pagination_response_schema[schema_out] # type:ignore[index]
},
url_name=url_name,
description=description,
Expand Down
3 changes: 1 addition & 2 deletions ninja_extra/controllers/route/route_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ async def __call__(
context = get_route_execution_context(
request,
temporal_response,
self.route.permissions
or _api_controller.permission_classes, # type:ignore[arg-type]
self.route.permissions or _api_controller.permission_classes, # type:ignore[arg-type]
*args,
**kwargs,
)
Expand Down
8 changes: 6 additions & 2 deletions ninja_extra/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,18 @@ async def run(self, request: HttpRequest, **kw: Any) -> HttpResponseBase: # typ
values = await self._get_values(request, kw, temporal_response) # type: ignore
ctx.kwargs.update(values)
result = await self.view_func(request, **values)
_processed_results = await self._result_to_response(request, result, temporal_response) # type: ignore
_processed_results = await self._result_to_response(
request, result, temporal_response
) # type: ignore
return cast(HttpResponseBase, _processed_results)
except Exception as e:
return self.api.on_exception(request, e)


class PathView(NinjaPathView):
async def _async_view(self, request: HttpRequest, *args, **kwargs) -> HttpResponseBase: # type: ignore
async def _async_view( # type: ignore
self, request: HttpRequest, *args, **kwargs
) -> HttpResponseBase:
return await super(PathView, self)._async_view(request, *args, **kwargs)

def _sync_view(self, request: HttpRequest, *args, **kwargs) -> HttpResponseBase: # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion ninja_extra/permissions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __ror__( # type:ignore[misc]
return OperandHolder(OR, other, self)

def __invert__( # type:ignore[misc]
self: Union[Type["BasePermission"], "BasePermission"]
self: Union[Type["BasePermission"], "BasePermission"],
) -> "SingleOperandHolder[NOT]":
return SingleOperandHolder(NOT, self)

Expand Down
2 changes: 1 addition & 1 deletion ninja_extra/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def add_api_operation(
exclude_none: bool = False,
url_name: Optional[str] = None,
include_in_schema: bool = True,
openapi_extra: Optional[Dict[str, Any]] = None
openapi_extra: Optional[Dict[str, Any]] = None,
) -> None:
if path not in self.path_operations:
path_view = PathView()
Expand Down
2 changes: 1 addition & 1 deletion ninja_extra/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_object_or_exception(
klass: Union[Type[Model], QuerySet],
error_message: str = None,
exception: Type[APIException] = NotFound,
**kwargs: Any
**kwargs: Any,
) -> Any:
queryset = _get_queryset(klass)
_validate_queryset(klass, queryset)
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ test = [
"pytest",
"pytest-cov",
"pytest-django",
"pytest-asyncio",
"black ==23.10.1",
"mypy == 1.6.1",
"ruff ==0.1.4",
"pytest-asyncio==0.20.3",
"mypy == 1.7.1",
"ruff ==0.1.7",
"ninja-schema>=0.13.4",
"django-stubs",
]
Expand Down