Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c4a22b

Browse files
cclaussViicos
andauthored
Addflake8-pie Ruff rules (#11982)
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
1 parentddb1a68 commit0c4a22b

File tree

10 files changed

+9
-16
lines changed

10 files changed

+9
-16
lines changed

‎pydantic/main.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ def model_post_init(self, context: Any, /) -> None:
591591
"""Override this method to perform additional initialization after `__init__` and `model_construct`.
592592
This is useful if you want to do some validation that requires the entire model to be initialized.
593593
"""
594-
pass
595594

596595
@classmethod
597596
defmodel_rebuild(
@@ -837,7 +836,6 @@ def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
837836
You may want to override [`__pydantic_on_complete__()`][pydantic.main.BaseModel.__pydantic_on_complete__]
838837
instead, which is called once the class and its fields are fully initialized and ready for validation.
839838
"""
840-
pass
841839

842840
@classmethod
843841
def__pydantic_on_complete__(cls)->None:
@@ -849,7 +847,6 @@ def __pydantic_on_complete__(cls) -> None:
849847
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
850848
[`model_rebuild()`][pydantic.main.BaseModel.model_rebuild].
851849
"""
852-
pass
853850

854851
def__class_getitem__(
855852
cls,typevar_values:type[Any]|tuple[type[Any], ...]

‎pydantic/plugin/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ def on_enter(
131131
by_alias: Whether to use the field's alias to match the input data to an attribute.
132132
by_name: Whether to use the field's name to match the input data to an attribute.
133133
"""
134-
pass
135134

136135

137136
classValidateJsonHandlerProtocol(BaseValidateHandlerProtocol,Protocol):
@@ -158,7 +157,6 @@ def on_enter(
158157
by_alias: Whether to use the field's alias to match the input data to an attribute.
159158
by_name: Whether to use the field's name to match the input data to an attribute.
160159
"""
161-
pass
162160

163161

164162
StringInput:TypeAlias='dict[str, StringInput]'
@@ -185,4 +183,3 @@ def on_enter(
185183
by_alias: Whether to use the field's alias to match the input data to an attribute.
186184
by_name: Whether to use the field's name to match the input data to an attribute.
187185
"""
188-
pass

‎pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,13 @@ select = [
207207
'T10',# flake8-debugger
208208
'T20',# flake8-print
209209
'C4',# flake8-comprehensions
210+
'PIE',# flake8-pie
210211
'PYI006',# flake8-pyi
211212
'PYI062',# flake8-pyi
212213
'PYI063',# flake8-pyi
213214
'PYI066',# flake8-pyi
214215
]
215-
ignore = ['D105','D107','D205','D415','E501','B011','B028','B904']
216+
ignore = ['D105','D107','D205','D415','E501','B011','B028','B904','PIE804']
216217
flake8-quotes = {inline-quotes ='single',multiline-quotes ='double'}
217218
isort = {known-first-party = ['pydantic','tests'] }
218219
mccabe = {max-complexity =14 }
@@ -222,7 +223,9 @@ pydocstyle = { convention = 'google' }
222223
'docs/*' = ['D']
223224
'pydantic/__init__.py' = ['F405','F403','D']
224225
'tests/test_forward_ref.py' = ['F821']
226+
'tests/test_main.py' = ['PIE807']
225227
'tests/*' = ['D','B','C4']
228+
'pydantic/_internal/_known_annotated_metadata.py' = ['PIE800']
226229
'pydantic/deprecated/*' = ['D','PYI']
227230
'pydantic/color.py' = ['PYI']
228231
'pydantic/_internal/_decorators_v1.py' = ['PYI']

‎tests/test_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def run_example(example: CodeExample, eval_example: EvalExample, mocker: Any) ->
9595

9696
group_name=prefix_settings.get('group')
9797

98-
eval_example.set_config(ruff_ignore=['D','T','B','C4','E721','Q001'],line_length=LINE_LENGTH)
98+
eval_example.set_config(ruff_ignore=['D','T','B','C4','E721','Q001','PIE790'],line_length=LINE_LENGTH)
9999
if'# ignore-above'inexample.source:
100100
eval_example.set_config(ruff_ignore=eval_example.config.ruff_ignore+ ['E402'],line_length=LINE_LENGTH)
101101
ifgroup_name:

‎tests/test_fields.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ def test_fastapi_compatibility_hack() -> None:
263263
classBody(FieldInfo):
264264
"""A reproduction of the FastAPI's `Body` param."""
265265

266-
pass
267-
268266
field=Body()
269267
# Assigning after doesn't update `_attributes_set`, which is currently
270268
# relied on to merge `FieldInfo` instances during field creation.

‎tests/test_generics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class Model(BaseModel, Generic[T, S]):
321321

322322
# This error message, which comes from `typing`, changed 'parameters' to 'arguments' in 3.11
323323
error_message=str(exc_info.value)
324-
asserterror_message.startswith('Too many parameters')orerror_message.startswith('Too many arguments')
324+
asserterror_message.startswith(('Too many parameters','Too many arguments'))
325325
asserterror_message.endswith(
326326
" for <class 'tests.test_generics.test_parameter_count.<locals>.Model'>; actual 3, expected 2"
327327
)

‎tests/test_serialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ class Model(BaseModel):
778778
y:int
779779

780780
ser_x=field_serializer('x')(ser1)
781-
ser_x=field_serializer('y')(ser2)
781+
ser_x=field_serializer('y')(ser2)# noqa: PIE794
782782

783783
assertModel(x=1,y=2).model_dump()== {'x':1,'y':'ser2'}
784784

‎tests/test_titles.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ class MyDataclass:
207207
deftest_typeddict_model_title_generator(model_title_generator,TypedDict):
208208
classMyTypedDict(TypedDict):
209209
__pydantic_config__=ConfigDict(model_title_generator=model_title_generator)
210-
pass
211210

212211
assertTypeAdapter(MyTypedDict).json_schema()== {
213212
'properties': {},
@@ -429,7 +428,6 @@ class MyDataclass:
429428

430429
classMyTypedDict(TypedDict):
431430
__pydantic_config__=ConfigDict(model_title_generator=lambdam:invalid_return_value)
432-
pass
433431

434432
TypeAdapter(MyTypedDict).json_schema()
435433

‎tests/test_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,7 @@ class Model(BaseModel):
25452545
y:int
25462546

25472547
val_x=field_validator('x')(val1)
2548-
val_x=field_validator('y')(val2)
2548+
val_x=field_validator('y')(val2)# noqa: PIE794
25492549

25502550
assertModel(x=1,y=2).model_dump()== {'x':1,'y':4}
25512551

‎tests/typechecking/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def incompatible_type_var(cls, value: Any, handler: ModelWrapValidatorHandler[in
7777
the `_ModelType` type var will thus bind to `Self`. It is then expected to have
7878
`handler: ModelWrapValidatorHandler[_ModelType]` and the return type as `-> _ModelType`.
7979
"""
80-
...
80+
...# noqa: PIE790
8181

8282
@model_validator(mode='wrap')
8383
@classmethod

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp