Skip to content

Commit 8e2c5a8

Browse files
committed
Pyflakes pre-commit hook
1 parent 840bfbd commit 8e2c5a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+84
-332
lines changed

.pre-commit-config.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ repos:
3737
language: system
3838
require_serial: true
3939
types: [python]
40+
41+
- id: pyflakes
42+
name: pyflakes
43+
entry: pyflakes
44+
language: system
45+
require_serial: true
46+
types: [python]

openapi_core/app.py

-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
"""OpenAPI core app module"""
2-
import warnings
3-
from dataclasses import dataclass
4-
from dataclasses import field
5-
from functools import lru_cache
62
from pathlib import Path
7-
from typing import Any
8-
from typing import Hashable
9-
from typing import Mapping
103
from typing import Optional
11-
from typing import Type
12-
from typing import TypeVar
13-
from typing import Union
144

155
from jsonschema._utils import Unset
166
from jsonschema.validators import _UNSET
@@ -19,7 +9,6 @@
199
from jsonschema_path.typing import Schema
2010
from openapi_spec_validator import validate
2111
from openapi_spec_validator.validation.exceptions import ValidatorDetectError
22-
from openapi_spec_validator.validation.types import SpecValidatorType
2312
from openapi_spec_validator.versions.datatypes import SpecVersion
2413
from openapi_spec_validator.versions.exceptions import OpenAPIVersionNotFound
2514
from openapi_spec_validator.versions.shortcuts import get_spec_version

openapi_core/casting/schemas/casters.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from typing import TYPE_CHECKING
21
from typing import Any
3-
from typing import Callable
42
from typing import Generic
53
from typing import Iterable
64
from typing import List
@@ -12,7 +10,6 @@
1210

1311
from jsonschema_path import SchemaPath
1412

15-
from openapi_core.casting.schemas.datatypes import CasterCallable
1613
from openapi_core.casting.schemas.exceptions import CastError
1714
from openapi_core.schema.schemas import get_properties
1815
from openapi_core.util import forcebool

openapi_core/casting/schemas/factories.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from typing import Dict
21
from typing import Optional
32

43
from jsonschema_path import SchemaPath
54

65
from openapi_core.casting.schemas.casters import SchemaCaster
76
from openapi_core.casting.schemas.casters import TypesCaster
8-
from openapi_core.casting.schemas.datatypes import CasterCallable
9-
from openapi_core.util import forcebool
107
from openapi_core.validation.schemas.datatypes import FormatValidatorsDict
118
from openapi_core.validation.schemas.factories import SchemaValidatorsFactory
129

openapi_core/configurations.py

-58
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,21 @@
1-
import warnings
21
from dataclasses import dataclass
3-
from dataclasses import field
4-
from functools import lru_cache
5-
from pathlib import Path
6-
from typing import Any
7-
from typing import Hashable
8-
from typing import Mapping
9-
from typing import Optional
10-
from typing import Type
11-
from typing import TypeVar
122
from typing import Union
133

144
from jsonschema._utils import Unset
155
from jsonschema.validators import _UNSET
16-
from jsonschema_path import SchemaPath
17-
from jsonschema_path.handlers.protocols import SupportsRead
18-
from jsonschema_path.typing import Schema
19-
from openapi_spec_validator import validate
206
from openapi_spec_validator.validation.types import SpecValidatorType
21-
from openapi_spec_validator.versions.datatypes import SpecVersion
22-
from openapi_spec_validator.versions.exceptions import OpenAPIVersionNotFound
23-
from openapi_spec_validator.versions.shortcuts import get_spec_version
247

25-
from openapi_core.exceptions import SpecError
26-
from openapi_core.protocols import Request
27-
from openapi_core.protocols import Response
28-
from openapi_core.protocols import WebhookRequest
29-
from openapi_core.types import AnyRequest
308
from openapi_core.unmarshalling.configurations import UnmarshallerConfig
31-
from openapi_core.unmarshalling.request import (
32-
UNMARSHALLERS as REQUEST_UNMARSHALLERS,
33-
)
34-
from openapi_core.unmarshalling.request import (
35-
WEBHOOK_UNMARSHALLERS as WEBHOOK_REQUEST_UNMARSHALLERS,
36-
)
37-
from openapi_core.unmarshalling.request.datatypes import RequestUnmarshalResult
38-
from openapi_core.unmarshalling.request.protocols import RequestUnmarshaller
39-
from openapi_core.unmarshalling.request.protocols import (
40-
WebhookRequestUnmarshaller,
41-
)
429
from openapi_core.unmarshalling.request.types import RequestUnmarshallerType
4310
from openapi_core.unmarshalling.request.types import (
4411
WebhookRequestUnmarshallerType,
4512
)
46-
from openapi_core.unmarshalling.response import (
47-
UNMARSHALLERS as RESPONSE_UNMARSHALLERS,
48-
)
49-
from openapi_core.unmarshalling.response import (
50-
WEBHOOK_UNMARSHALLERS as WEBHOOK_RESPONSE_UNMARSHALLERS,
51-
)
52-
from openapi_core.unmarshalling.response.datatypes import (
53-
ResponseUnmarshalResult,
54-
)
55-
from openapi_core.unmarshalling.response.protocols import ResponseUnmarshaller
56-
from openapi_core.unmarshalling.response.protocols import (
57-
WebhookResponseUnmarshaller,
58-
)
5913
from openapi_core.unmarshalling.response.types import ResponseUnmarshallerType
6014
from openapi_core.unmarshalling.response.types import (
6115
WebhookResponseUnmarshallerType,
6216
)
63-
from openapi_core.validation.request import VALIDATORS as REQUEST_VALIDATORS
64-
from openapi_core.validation.request import (
65-
WEBHOOK_VALIDATORS as WEBHOOK_REQUEST_VALIDATORS,
66-
)
67-
from openapi_core.validation.request.protocols import RequestValidator
68-
from openapi_core.validation.request.protocols import WebhookRequestValidator
6917
from openapi_core.validation.request.types import RequestValidatorType
7018
from openapi_core.validation.request.types import WebhookRequestValidatorType
71-
from openapi_core.validation.response import VALIDATORS as RESPONSE_VALIDATORS
72-
from openapi_core.validation.response import (
73-
WEBHOOK_VALIDATORS as WEBHOOK_RESPONSE_VALIDATORS,
74-
)
75-
from openapi_core.validation.response.protocols import ResponseValidator
76-
from openapi_core.validation.response.protocols import WebhookResponseValidator
7719
from openapi_core.validation.response.types import ResponseValidatorType
7820
from openapi_core.validation.response.types import WebhookResponseValidatorType
7921

openapi_core/contrib/aiohttp/requests.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"""OpenAPI core contrib aiohttp requests module"""
22
from __future__ import annotations
33

4-
from typing import cast
5-
64
from aiohttp import web
7-
from asgiref.sync import AsyncToSync
85

96
from openapi_core.datatypes import RequestParameters
107

openapi_core/contrib/django/handlers.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Callable
44
from typing import Dict
55
from typing import Iterable
6-
from typing import Optional
76
from typing import Type
87

98
from django.http import JsonResponse

openapi_core/contrib/django/middlewares.py

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
DjangoOpenAPIValidRequestHandler,
1414
)
1515
from openapi_core.contrib.django.integrations import DjangoIntegration
16-
from openapi_core.contrib.django.requests import DjangoOpenAPIRequest
17-
from openapi_core.contrib.django.responses import DjangoOpenAPIResponse
18-
from openapi_core.unmarshalling.processors import UnmarshallingProcessor
1916

2017

2118
class DjangoOpenAPIMiddleware(DjangoIntegration):

openapi_core/contrib/falcon/middlewares.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""OpenAPI core contrib falcon middlewares module"""
22
from typing import Any
3-
from typing import Optional
43
from typing import Type
54
from typing import Union
65

@@ -19,7 +18,6 @@
1918
from openapi_core.contrib.falcon.integrations import FalconIntegration
2019
from openapi_core.contrib.falcon.requests import FalconOpenAPIRequest
2120
from openapi_core.contrib.falcon.responses import FalconOpenAPIResponse
22-
from openapi_core.unmarshalling.processors import UnmarshallingProcessor
2321
from openapi_core.unmarshalling.request.types import RequestUnmarshallerType
2422
from openapi_core.unmarshalling.response.types import ResponseUnmarshallerType
2523

openapi_core/contrib/flask/decorators.py

-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from functools import wraps
33
from typing import Any
44
from typing import Callable
5-
from typing import Optional
65
from typing import Type
76

87
from flask.globals import request
@@ -17,9 +16,6 @@
1716
from openapi_core.contrib.flask.providers import FlaskRequestProvider
1817
from openapi_core.contrib.flask.requests import FlaskOpenAPIRequest
1918
from openapi_core.contrib.flask.responses import FlaskOpenAPIResponse
20-
from openapi_core.unmarshalling.processors import UnmarshallingProcessor
21-
from openapi_core.unmarshalling.request.types import RequestUnmarshallerType
22-
from openapi_core.unmarshalling.response.types import ResponseUnmarshallerType
2319

2420

2521
class FlaskOpenAPIViewDecorator(FlaskIntegration):

openapi_core/contrib/starlette/handlers.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""OpenAPI core contrib starlette handlers module"""
22
from typing import Any
3-
from typing import Callable
43
from typing import Dict
54
from typing import Iterable
6-
from typing import Optional
75
from typing import Type
86

97
from starlette.middleware.base import RequestResponseEndpoint

openapi_core/contrib/starlette/integrations.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from typing import Callable
2-
3-
from aioitertools.builtins import list as alist
41
from aioitertools.itertools import tee as atee
52
from starlette.requests import Request
63
from starlette.responses import Response

openapi_core/contrib/starlette/middlewares.py

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from starlette.middleware.base import RequestResponseEndpoint
44
from starlette.requests import Request
55
from starlette.responses import Response
6-
from starlette.responses import StreamingResponse
76
from starlette.types import ASGIApp
87

98
from openapi_core import OpenAPI
@@ -14,9 +13,6 @@
1413
StarletteOpenAPIValidRequestHandler,
1514
)
1615
from openapi_core.contrib.starlette.integrations import StarletteIntegration
17-
from openapi_core.contrib.starlette.requests import StarletteOpenAPIRequest
18-
from openapi_core.contrib.starlette.responses import StarletteOpenAPIResponse
19-
from openapi_core.unmarshalling.processors import AsyncUnmarshallingProcessor
2016

2117

2218
class StarletteOpenAPIMiddleware(StarletteIntegration, BaseHTTPMiddleware):

openapi_core/contrib/starlette/requests.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""OpenAPI core contrib starlette requests module"""
22
from typing import Optional
33

4-
from asgiref.sync import AsyncToSync
54
from starlette.requests import Request
65

76
from openapi_core.datatypes import RequestParameters

openapi_core/deserializing/media_types/deserializers.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import warnings
21
from typing import Any
32
from typing import Mapping
43
from typing import Optional
5-
from typing import cast
64
from xml.etree.ElementTree import ParseError
75

86
from jsonschema_path import SchemaPath
@@ -106,7 +104,6 @@ def evolve(
106104
def decode(self, location: Mapping[str, Any]) -> Mapping[str, Any]:
107105
# schema is required for multipart
108106
assert self.schema is not None
109-
schema_props = self.schema.get("properties")
110107
properties = {}
111108
for prop_name, prop_schema in get_properties(self.schema).items():
112109
try:
@@ -127,7 +124,6 @@ def decode_property(
127124
location: Mapping[str, Any],
128125
) -> Any:
129126
if self.encoding is None or prop_name not in self.encoding:
130-
prop_schema_type = prop_schema.getkey("type", "")
131127
if self.mimetype == "application/x-www-form-urlencoded":
132128
# default serialization strategy for complex objects
133129
# in the application/x-www-form-urlencoded

openapi_core/deserializing/media_types/factories.py

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
from jsonschema_path import SchemaPath
55

6-
from openapi_core.deserializing.media_types.datatypes import (
7-
DeserializerCallable,
8-
)
96
from openapi_core.deserializing.media_types.datatypes import (
107
MediaTypeDeserializersDict,
118
)

openapi_core/deserializing/media_types/util.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from json import loads
33
from typing import Any
44
from typing import Mapping
5-
from typing import Union
65
from urllib.parse import parse_qsl
76
from xml.etree.ElementTree import Element
87
from xml.etree.ElementTree import fromstring

openapi_core/deserializing/styles/datatypes.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import Any
22
from typing import Callable
33
from typing import Dict
4-
from typing import List
54
from typing import Mapping
65

76
DeserializerCallable = Callable[[bool, str, str, Mapping[str, Any]], Any]

openapi_core/deserializing/styles/deserializers.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import warnings
22
from typing import Any
3-
from typing import Callable
4-
from typing import List
53
from typing import Mapping
64
from typing import Optional
75

8-
from jsonschema_path import SchemaPath
9-
106
from openapi_core.deserializing.exceptions import DeserializeError
117
from openapi_core.deserializing.styles.datatypes import DeserializerCallable
12-
from openapi_core.deserializing.styles.exceptions import (
13-
EmptyQueryParameterValue,
14-
)
158

169

1710
class StyleDeserializer:

openapi_core/deserializing/styles/factories.py

-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import re
2-
from functools import partial
3-
from typing import Any
4-
from typing import Dict
5-
from typing import Mapping
61
from typing import Optional
72

83
from jsonschema_path import SchemaPath
94

10-
from openapi_core.deserializing.styles.datatypes import DeserializerCallable
115
from openapi_core.deserializing.styles.datatypes import StyleDeserializersDict
126
from openapi_core.deserializing.styles.deserializers import StyleDeserializer
137

openapi_core/deserializing/styles/util.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Any
44
from typing import List
55
from typing import Mapping
6-
from typing import Optional
76

87
from openapi_core.schema.protocols import SuportsGetAll
98
from openapi_core.schema.protocols import SuportsGetList

openapi_core/extensions/models/factories.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""OpenAPI X-Model extension factories module"""
22
from dataclasses import make_dataclass
3-
from pydoc import ErrorDuringImport
43
from pydoc import locate
54
from typing import Any
65
from typing import Dict
76
from typing import Iterable
8-
from typing import Optional
97
from typing import Type
108

119
from jsonschema_path import SchemaPath

openapi_core/protocols.py

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from typing import runtime_checkable
77

88
from openapi_core.datatypes import RequestParameters
9-
from openapi_core.typing import RequestType
10-
from openapi_core.typing import ResponseType
119

1210

1311
@runtime_checkable

openapi_core/schema/parameters.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
from typing import Any
2-
from typing import Dict
3-
from typing import Mapping
4-
from typing import Optional
51
from typing import Tuple
62

73
from jsonschema_path import SchemaPath
84

9-
from openapi_core.schema.protocols import SuportsGetAll
10-
from openapi_core.schema.protocols import SuportsGetList
11-
125

136
def get_style(
147
param_or_header: SchemaPath, default_location: str = "header"

0 commit comments

Comments
 (0)