Skip to content

Commit 332e77b

Browse files
Update to Ruff 0.4.8 (pydantic#9585)
Co-authored-by: sydney-runkle <[email protected]>
1 parent 0c180c8 commit 332e77b

File tree

86 files changed

+194
-1616
lines changed

Some content is hidden

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

86 files changed

+194
-1616
lines changed

pdm.lock

+19-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pydantic/_internal/_dataclasses.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Private logic for creating pydantic dataclasses."""
2+
23
from __future__ import annotations as _annotations
34

45
import dataclasses

pydantic/_internal/_decorators.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Logic related to validators applied to models etc. via the `@field_validator` and `@model_validator` decorators."""
2+
23
from __future__ import annotations as _annotations
34

45
from collections import deque

pydantic/_internal/_decorators_v1.py

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Logic for V1 validators, e.g. `@validator` and `@root_validator`."""
2+
23
from __future__ import annotations as _annotations
34

45
from inspect import Parameter, signature
@@ -14,36 +15,31 @@
1415
class V1OnlyValueValidator(Protocol):
1516
"""A simple validator, supported for V1 validators and V2 validators."""
1617

17-
def __call__(self, __value: Any) -> Any:
18-
...
18+
def __call__(self, __value: Any) -> Any: ...
1919

2020

2121
class V1ValidatorWithValues(Protocol):
2222
"""A validator with `values` argument, supported for V1 validators and V2 validators."""
2323

24-
def __call__(self, __value: Any, values: dict[str, Any]) -> Any:
25-
...
24+
def __call__(self, __value: Any, values: dict[str, Any]) -> Any: ...
2625

2726

2827
class V1ValidatorWithValuesKwOnly(Protocol):
2928
"""A validator with keyword only `values` argument, supported for V1 validators and V2 validators."""
3029

31-
def __call__(self, __value: Any, *, values: dict[str, Any]) -> Any:
32-
...
30+
def __call__(self, __value: Any, *, values: dict[str, Any]) -> Any: ...
3331

3432

3533
class V1ValidatorWithKwargs(Protocol):
3634
"""A validator with `kwargs` argument, supported for V1 validators and V2 validators."""
3735

38-
def __call__(self, __value: Any, **kwargs: Any) -> Any:
39-
...
36+
def __call__(self, __value: Any, **kwargs: Any) -> Any: ...
4037

4138

4239
class V1ValidatorWithValuesAndKwargs(Protocol):
4340
"""A validator with `values` and `kwargs` arguments, supported for V1 validators and V2 validators."""
4441

45-
def __call__(self, __value: Any, values: dict[str, Any], **kwargs: Any) -> Any:
46-
...
42+
def __call__(self, __value: Any, values: dict[str, Any], **kwargs: Any) -> Any: ...
4743

4844

4945
V1Validator = Union[
@@ -117,24 +113,21 @@ def wrapper2(value: Any, _: core_schema.ValidationInfo) -> Any:
117113
class V1RootValidatorFunction(Protocol):
118114
"""A simple root validator, supported for V1 validators and V2 validators."""
119115

120-
def __call__(self, __values: RootValidatorValues) -> RootValidatorValues:
121-
...
116+
def __call__(self, __values: RootValidatorValues) -> RootValidatorValues: ...
122117

123118

124119
class V2CoreBeforeRootValidator(Protocol):
125120
"""V2 validator with mode='before'."""
126121

127-
def __call__(self, __values: RootValidatorValues, __info: core_schema.ValidationInfo) -> RootValidatorValues:
128-
...
122+
def __call__(self, __values: RootValidatorValues, __info: core_schema.ValidationInfo) -> RootValidatorValues: ...
129123

130124

131125
class V2CoreAfterRootValidator(Protocol):
132126
"""V2 validator with mode='after'."""
133127

134128
def __call__(
135129
self, __fields_tuple: RootValidatorFieldsTuple, __info: core_schema.ValidationInfo
136-
) -> RootValidatorFieldsTuple:
137-
...
130+
) -> RootValidatorFieldsTuple: ...
138131

139132

140133
def make_v1_generic_root_validator(

pydantic/_internal/_docs_extraction.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Utilities related to attribute docstring extraction."""
2+
23
from __future__ import annotations
34

45
import ast

pydantic/_internal/_fields.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Private logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`."""
2+
23
from __future__ import annotations as _annotations
34

45
import dataclasses

pydantic/_internal/_generate_schema.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Convert python types to pydantic-core schema."""
2+
23
from __future__ import annotations as _annotations
34

45
import collections.abc
@@ -705,12 +706,10 @@ def _resolve_forward_ref(self, obj: Any) -> Any:
705706
return obj
706707

707708
@overload
708-
def _get_args_resolving_forward_refs(self, obj: Any, required: Literal[True]) -> tuple[Any, ...]:
709-
...
709+
def _get_args_resolving_forward_refs(self, obj: Any, required: Literal[True]) -> tuple[Any, ...]: ...
710710

711711
@overload
712-
def _get_args_resolving_forward_refs(self, obj: Any) -> tuple[Any, ...] | None:
713-
...
712+
def _get_args_resolving_forward_refs(self, obj: Any) -> tuple[Any, ...] | None: ...
714713

715714
def _get_args_resolving_forward_refs(self, obj: Any, required: bool = False) -> tuple[Any, ...] | None:
716715
args = get_args(obj)

pydantic/_internal/_generics.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
if TYPE_CHECKING:
3838

3939
class LimitedDict(dict, MutableMapping[KT, VT]):
40-
def __init__(self, size_limit: int = _LIMITED_DICT_SIZE):
41-
...
40+
def __init__(self, size_limit: int = _LIMITED_DICT_SIZE): ...
4241

4342
else:
4443

pydantic/_internal/_git.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Git utilities, adopted from mypy's git utilities (https://github.com/python/mypy/blob/master/mypy/git.py)."""
2+
23
from __future__ import annotations
34

45
import os

pydantic/_internal/_model_construction.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Private logic for creating models."""
2+
23
from __future__ import annotations as _annotations
34

45
import builtins

pydantic/_internal/_repr.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tools to provide pretty/human-readable display of objects."""
2+
23
from __future__ import annotations as _annotations
34

45
import types

pydantic/_internal/_schema_generation_shared.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Types and utility functions used by various other internal tools."""
2+
23
from __future__ import annotations
34

45
from typing import TYPE_CHECKING, Any, Callable

pydantic/_internal/_std_types_schema.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Import of this module is deferred since it contains imports of many standard library modules.
44
"""
5+
56
from __future__ import annotations as _annotations
67

78
import collections

pydantic/_internal/_typing_extra.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Logic for interacting with type annotations, mostly extensions, shims and hacks to wrap python's typing module."""
2+
23
from __future__ import annotations as _annotations
34

45
import dataclasses

pydantic/_internal/_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
This should be reduced as much as possible with functions only used in one place, moved to that place.
44
"""
5+
56
from __future__ import annotations as _annotations
67

78
import dataclasses
@@ -276,8 +277,7 @@ def __repr_args__(self) -> _repr.ReprArgs:
276277

277278
if typing.TYPE_CHECKING:
278279

279-
def ClassAttribute(name: str, value: T) -> T:
280-
...
280+
def ClassAttribute(name: str, value: T) -> T: ...
281281

282282
else:
283283

pydantic/alias_generators.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Alias generators for converting between different capitalization conventions."""
2+
23
import re
34

45
__all__ = ('to_pascal', 'to_camel', 'to_snake')

pydantic/aliases.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Support for alias configurations."""
2+
23
from __future__ import annotations
34

45
import dataclasses

pydantic/annotated_handlers.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Type annotations to use with `__get_pydantic_core_schema__` and `__get_pydantic_json_schema__`."""
2+
23
from __future__ import annotations as _annotations
34

45
from typing import TYPE_CHECKING, Any, Union

pydantic/class_validators.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""`class_validators` module is a backport module from V1."""
2+
23
from ._migration import getattr_migration
34

45
__getattr__ = getattr_migration(__name__)

pydantic/color.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
See [`pydantic-extra-types.Color`](../usage/types/extra_types/color_types.md)
1212
for more information.
1313
"""
14+
1415
import math
1516
import re
1617
from colorsys import hls_to_rgb, rgb_to_hls

pydantic/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Configuration for Pydantic models."""
2+
23
from __future__ import annotations as _annotations
34

45
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Type, TypeVar, Union

pydantic/dataclasses.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Provide an enhanced dataclass that performs validation."""
2+
23
from __future__ import annotations as _annotations
34

45
import dataclasses
@@ -56,8 +57,7 @@ def dataclass(
5657
validate_on_init: bool | None = None,
5758
kw_only: bool = ...,
5859
slots: bool = ...,
59-
) -> type[PydanticDataclass]:
60-
...
60+
) -> type[PydanticDataclass]: ...
6161

6262
else:
6363

@@ -89,8 +89,7 @@ def dataclass(
8989
frozen: bool = False,
9090
config: ConfigDict | type[object] | None = None,
9191
validate_on_init: bool | None = None,
92-
) -> type[PydanticDataclass]:
93-
...
92+
) -> type[PydanticDataclass]: ...
9493

9594

9695
@dataclass_transform(field_specifiers=(dataclasses.field, Field, PrivateAttr))

pydantic/datetime_parse.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The `datetime_parse` module is a backport module from V1."""
2+
23
from ._migration import getattr_migration
34

45
__getattr__ = getattr_migration(__name__)

pydantic/decorator.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The `decorator` module is a backport module from V1."""
2+
23
from ._migration import getattr_migration
34

45
__getattr__ = getattr_migration(__name__)

pydantic/deprecated/class_validators.py

+9-18
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,24 @@
1919
if TYPE_CHECKING:
2020

2121
class _OnlyValueValidatorClsMethod(Protocol):
22-
def __call__(self, __cls: Any, __value: Any) -> Any:
23-
...
22+
def __call__(self, __cls: Any, __value: Any) -> Any: ...
2423

2524
class _V1ValidatorWithValuesClsMethod(Protocol):
26-
def __call__(self, __cls: Any, __value: Any, values: dict[str, Any]) -> Any:
27-
...
25+
def __call__(self, __cls: Any, __value: Any, values: dict[str, Any]) -> Any: ...
2826

2927
class _V1ValidatorWithValuesKwOnlyClsMethod(Protocol):
30-
def __call__(self, __cls: Any, __value: Any, *, values: dict[str, Any]) -> Any:
31-
...
28+
def __call__(self, __cls: Any, __value: Any, *, values: dict[str, Any]) -> Any: ...
3229

3330
class _V1ValidatorWithKwargsClsMethod(Protocol):
34-
def __call__(self, __cls: Any, **kwargs: Any) -> Any:
35-
...
31+
def __call__(self, __cls: Any, **kwargs: Any) -> Any: ...
3632

3733
class _V1ValidatorWithValuesAndKwargsClsMethod(Protocol):
38-
def __call__(self, __cls: Any, values: dict[str, Any], **kwargs: Any) -> Any:
39-
...
34+
def __call__(self, __cls: Any, values: dict[str, Any], **kwargs: Any) -> Any: ...
4035

4136
class _V1RootValidatorClsMethod(Protocol):
4237
def __call__(
4338
self, __cls: Any, __values: _decorators_v1.RootValidatorValues
44-
) -> _decorators_v1.RootValidatorValues:
45-
...
39+
) -> _decorators_v1.RootValidatorValues: ...
4640

4741
V1Validator = Union[
4842
_OnlyValueValidatorClsMethod,
@@ -171,8 +165,7 @@ def root_validator(
171165
) -> Callable[
172166
[_V1RootValidatorFunctionType],
173167
_V1RootValidatorFunctionType,
174-
]:
175-
...
168+
]: ...
176169

177170

178171
@overload
@@ -185,8 +178,7 @@ def root_validator(
185178
) -> Callable[
186179
[_V1RootValidatorFunctionType],
187180
_V1RootValidatorFunctionType,
188-
]:
189-
...
181+
]: ...
190182

191183

192184
@overload
@@ -200,8 +192,7 @@ def root_validator(
200192
) -> Callable[
201193
[_V1RootValidatorFunctionType],
202194
_V1RootValidatorFunctionType,
203-
]:
204-
...
195+
]: ...
205196

206197

207198
@deprecated(

0 commit comments

Comments
 (0)