Skip to content

Commit

Permalink
Merge pull request #1274 from c4ffein/just-ran-fmt
Browse files Browse the repository at this point in the history
Update code with `make fmt` and the pipeline to use the same `--preview` option of Ruff
  • Loading branch information
vitalik authored Dec 7, 2024
2 parents 081f073 + f397e83 commit d621a60
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ jobs:
- name: Install Dependencies
run: flit install --symlink
- name: Ruff format
run: ruff format --check ninja tests
run: ruff format --preview --check ninja tests
- name: Ruff lint
run: ruff check ninja tests
run: ruff check --preview ninja tests
- name: mypy
run: mypy ninja tests/mypy_test.py
42 changes: 19 additions & 23 deletions ninja/openapi/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,21 @@ def __init__(self, api: "NinjaAPI", path_prefix: str) -> None:
self.securitySchemes: DictStrAny = {}
self.all_operation_ids: Set = set()
extra_info = api.openapi_extra.get("info", {})
super().__init__(
[
("openapi", "3.1.0"),
(
"info",
{
"title": api.title,
"version": api.version,
"description": api.description,
**extra_info,
},
),
("paths", self.get_paths()),
("components", self.get_components()),
("servers", api.servers),
]
)
super().__init__([
("openapi", "3.1.0"),
(
"info",
{
"title": api.title,
"version": api.version,
"description": api.description,
**extra_info,
},
),
("paths", self.get_paths()),
("components", self.get_components()),
("servers", api.servers),
])
for k, v in api.openapi_extra.items():
if k not in self:
self[k] = v
Expand Down Expand Up @@ -242,12 +240,10 @@ def _create_multipart_schema_from_models(
content_type = BODY_CONTENT_TYPES["file"]

# get the various schemas
result = merge_schemas(
[
self._create_schema_from_model(model, remove_level=False)[0]
for model in models
]
)
result = merge_schemas([
self._create_schema_from_model(model, remove_level=False)[0]
for model in models
])
result["title"] = "MultiPartBodyParams"

return result, content_type
Expand Down
1 change: 0 additions & 1 deletion ninja/params/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"HeaderEx",
"PathEx",
"QueryEx",
"Router",
"P",
]

Expand Down
10 changes: 4 additions & 6 deletions ninja/testing/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,10 @@ def _build_request(
request.META = request_params.pop("META", {"REMOTE_ADDR": "127.0.0.1"})
request.FILES = request_params.pop("FILES", {})

request.META.update(
{
f"HTTP_{k.replace('-', '_')}": v
for k, v in request_params.pop("headers", {}).items()
}
)
request.META.update({
f"HTTP_{k.replace('-', '_')}": v
for k, v in request_params.pop("headers", {}).items()
})

request.headers = HttpHeaders(request.META)

Expand Down

0 comments on commit d621a60

Please sign in to comment.