Skip to content

Commit

Permalink
Use identity instead of equality when possible (pydantic#10712)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos authored Oct 25, 2024
1 parent 9b3e212 commit 19f7d41
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pydantic/_internal/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def count_positional_required_params(sig: Signature) -> int:
# First argument is the value being validated/serialized, and can have a default value
# (e.g. `float`, which has signature `(x=0, /)`). We assume other parameters (the info arg
# for instance) should be required, and thus without any default value.
and (param.default is Parameter.empty or param == parameters[0])
and (param.default is Parameter.empty or param is parameters[0])
)


Expand Down
4 changes: 2 additions & 2 deletions pydantic/_internal/_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ def collect_dataclass_fields(

if (
not dataclass_field.init
and dataclass_field.default == dataclasses.MISSING
and dataclass_field.default_factory == dataclasses.MISSING
and dataclass_field.default is dataclasses.MISSING
and dataclass_field.default_factory is dataclasses.MISSING
):
# TODO: We should probably do something with this so that validate_assignment behaves properly
# Issue: https://github.com/pydantic/pydantic/issues/5470
Expand Down
2 changes: 1 addition & 1 deletion pydantic/_internal/_generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def get_json_schema(schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSc
return json_schema

# we don't want to add the missing to the schema if it's the default one
default_missing = getattr(enum_type._missing_, '__func__', None) == Enum._missing_.__func__ # type: ignore
default_missing = getattr(enum_type._missing_, '__func__', None) is Enum._missing_.__func__ # pyright: ignore[reportFunctionMemberAccess]
enum_schema = core_schema.enum_schema(
enum_type,
cases,
Expand Down

0 comments on commit 19f7d41

Please sign in to comment.