Skip to content

Commit cc4f8dc

Browse files
committed
Fix linter errors
1 parent 0dd9f85 commit cc4f8dc

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

openapi_python_client/schema/openapi_schema_pydantic/path_item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Optional, Union
1+
from typing import TYPE_CHECKING, Optional
22

33
from pydantic import BaseModel, ConfigDict, Field
44

openapi_python_client/schema/openapi_schema_pydantic/responses.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from typing import Union
21

32
from .reference import ReferenceOr
43
from .response import Response

tests/test_schema/test_noisy_refs.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,19 @@
1717
import pytest
1818
from pydantic import TypeAdapter
1919

20-
from openapi_python_client.schema.openapi_schema_pydantic import Callback, Example, Header, Link, Parameter, PathItem, Reference, RequestBody, Response, Schema, SecurityScheme
21-
20+
from openapi_python_client.schema.openapi_schema_pydantic import (
21+
Callback,
22+
Example,
23+
Header,
24+
Link,
25+
Parameter,
26+
PathItem,
27+
Reference,
28+
RequestBody,
29+
Response,
30+
Schema,
31+
SecurityScheme,
32+
)
2233

2334
try:
2435
from openapi_python_client.schema.openapi_schema_pydantic.reference import ReferenceOr
@@ -34,10 +45,11 @@ def get_example(base_type):
3445
return schema["examples"][0]
3546
if "$defs" in schema:
3647
return schema["$defs"][base_type.__name__]["examples"][0]
37-
assert False, f"No example found for {base_type.__name__}"
48+
raise TypeError(f"No example found for {base_type.__name__}")
49+
3850

3951
def deannotate_type(t):
40-
while get_origin(t) == Annotated:
52+
while get_origin(t) is Annotated:
4153
t = get_args(t)[0]
4254
return t
4355

@@ -60,17 +72,18 @@ def deannotate_type(t):
6072
def test_type(ref_or_type, get_example_fn):
6173
base_type = None
6274
print(deannotate_type(ref_or_type))
63-
for base_type in get_args(deannotate_type(ref_or_type)):
64-
base_type = deannotate_type(base_type)
65-
if base_type != Reference:
75+
for maybe_annotated_type in get_args(deannotate_type(ref_or_type)):
76+
each_type = deannotate_type(maybe_annotated_type)
77+
if each_type is not Reference:
78+
base_type = each_type
6679
break
6780
assert base_type is not None
6881

6982
example = get_example_fn(base_type)
7083

7184
parsed = TypeAdapter(ref_or_type).validate_python(example)
72-
assert type(parsed) == get_origin(base_type) or base_type
85+
assert type(parsed) is get_origin(base_type) or base_type
7386

7487
example["$ref"] = "ref"
7588
parsed = TypeAdapter(ref_or_type).validate_python(example)
76-
assert type(parsed) == Reference
89+
assert type(parsed) is Reference

0 commit comments

Comments
 (0)