Skip to content

Commit 4b996e7

Browse files
committed
Run pre-commit run pyupgrade -a
1 parent c68d77b commit 4b996e7

File tree

14 files changed

+30
-31
lines changed

14 files changed

+30
-31
lines changed

openapi_spec_validator/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from argparse import ArgumentParser
44
from typing import Optional
5-
from typing import Sequence
5+
from collections.abc import Sequence
66

77
from jsonschema.exceptions import ValidationError
88
from jsonschema.exceptions import best_match

openapi_spec_validator/readers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
from jsonschema_path.typing import Schema
99

1010

11-
def read_from_stdin(filename: str) -> Tuple[Schema, str]:
11+
def read_from_stdin(filename: str) -> tuple[Schema, str]:
1212
return file_handler(sys.stdin), "" # type: ignore
1313

1414

15-
def read_from_filename(filename: str) -> Tuple[Schema, str]:
15+
def read_from_filename(filename: str) -> tuple[Schema, str]:
1616
if not path.isfile(filename):
1717
raise OSError(f"No such file: {filename}")
1818

openapi_spec_validator/schemas/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from jsonschema_path.typing import Schema
99

1010

11-
def get_schema(version: str) -> Tuple[Schema, str]:
11+
def get_schema(version: str) -> tuple[Schema, str]:
1212
schema_path = f"resources/schemas/v{version}/schema.json"
1313
ref = files("openapi_spec_validator") / schema_path
1414
with as_file(ref) as resource_path:

openapi_spec_validator/shortcuts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""OpenAPI spec validator shortcuts module."""
22
import warnings
3-
from typing import Mapping
3+
from collections.abc import Mapping
44
from typing import Optional
55
from typing import Type
66

@@ -50,7 +50,7 @@ def validate(
5050

5151
def validate_url(
5252
spec_url: str,
53-
cls: Optional[Type[SpecValidator]] = None,
53+
cls: Optional[type[SpecValidator]] = None,
5454
) -> None:
5555
spec = all_urls_handler(spec_url)
5656
return validate(spec, base_uri=spec_url, cls=cls)
@@ -82,7 +82,7 @@ def validate_spec(
8282
def validate_spec_url(
8383
spec_url: str,
8484
validator: Optional[SupportsValidation] = None,
85-
cls: Optional[Type[SpecValidator]] = None,
85+
cls: Optional[type[SpecValidator]] = None,
8686
) -> None:
8787
warnings.warn(
8888
"validate_spec_url shortcut is deprecated. Use validate_url instead.",

openapi_spec_validator/validation/caches.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Generic
2-
from typing import Iterable
3-
from typing import Iterator
2+
from collections.abc import Iterable
3+
from collections.abc import Iterator
44
from typing import List
55
from typing import TypeVar
66

@@ -14,7 +14,7 @@ class CachedIterable(Iterable[T], Generic[T]):
1414
It should not be iterated by his own.
1515
"""
1616

17-
cache: List[T]
17+
cache: list[T]
1818
iter: Iterator[T]
1919
completed: bool
2020

openapi_spec_validator/validation/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from functools import wraps
44
from typing import Any
55
from typing import Callable
6-
from typing import Iterable
7-
from typing import Iterator
6+
from collections.abc import Iterable
7+
from collections.abc import Iterator
88
from typing import TypeVar
99

1010
from jsonschema.exceptions import ValidationError

openapi_spec_validator/validation/keywords.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import string
22
from typing import TYPE_CHECKING
33
from typing import Any
4-
from typing import Sequence
5-
from typing import Iterator
4+
from collections.abc import Sequence
5+
from collections.abc import Iterator
66
from typing import List
77
from typing import Optional
88
from typing import cast
@@ -68,7 +68,7 @@ class SchemaValidator(KeywordValidator):
6868
def __init__(self, registry: "KeywordValidatorRegistry"):
6969
super().__init__(registry)
7070

71-
self.schema_ids_registry: Optional[List[int]] = []
71+
self.schema_ids_registry: Optional[list[int]] = []
7272

7373
@property
7474
def default_validator(self) -> ValueValidator:
@@ -305,7 +305,7 @@ class OperationValidator(KeywordValidator):
305305
def __init__(self, registry: "KeywordValidatorRegistry"):
306306
super().__init__(registry)
307307

308-
self.operation_ids_registry: Optional[List[str]] = []
308+
self.operation_ids_registry: Optional[list[str]] = []
309309

310310
@property
311311
def responses_validator(self) -> ResponsesValidator:
@@ -356,8 +356,7 @@ def __call__(
356356
for path in self._get_path_params_from_url(url):
357357
if path not in all_params:
358358
yield UnresolvableParameterError(
359-
"Path parameter '{}' for '{}' operation in '{}' "
360-
"was not resolved".format(path, name, url)
359+
f"Path parameter '{path}' for '{name}' operation in '{url}' was not resolved"
361360
)
362361
return
363362

openapi_spec_validator/validation/protocols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterator
1+
from collections.abc import Iterator
22
from typing import Optional
33
from typing import Protocol
44
from typing import runtime_checkable

openapi_spec_validator/validation/proxies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import warnings
33
from collections.abc import Hashable
44
from typing import Any
5-
from typing import Iterator
6-
from typing import Mapping
5+
from collections.abc import Iterator
6+
from collections.abc import Mapping
77
from typing import Optional
88
from typing import Tuple
99

@@ -59,7 +59,7 @@ def iter_errors(
5959

6060

6161
class DetectValidatorProxy:
62-
def __init__(self, choices: Mapping[Tuple[str, str], SpecValidatorProxy]):
62+
def __init__(self, choices: Mapping[tuple[str, str], SpecValidatorProxy]):
6363
self.choices = choices
6464

6565
def detect(self, instance: Schema) -> SpecValidatorProxy:

openapi_spec_validator/validation/registries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
from __future__ import annotations
22

33
from typing import DefaultDict
4-
from typing import Mapping
4+
from collections.abc import Mapping
55
from typing import Type
66

77
from openapi_spec_validator.validation.keywords import KeywordValidator
88

99

1010
class KeywordValidatorRegistry(DefaultDict[str, KeywordValidator]):
1111
def __init__(
12-
self, keyword_validators: Mapping[str, Type[KeywordValidator]]
12+
self, keyword_validators: Mapping[str, type[KeywordValidator]]
1313
):
1414
super().__init__()
1515
self.keyword_validators = keyword_validators

0 commit comments

Comments
 (0)