Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/cappa/class_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def detect(cls: type) -> bool:
@dataclasses.dataclass
class Field:
name: str
annotation: type
default: typing.Any | EmptyType = Empty
default_factory: typing.Any | EmptyType = Empty
metadata: dict[str, Any] = dataclasses.field(default_factory=lambda: {})
Expand All @@ -47,7 +46,6 @@ def collect(cls, typ: type) -> list[Self]:
continue
field = cls(
name=f.name,
annotation=f.type, # type: ignore
default=f.default if f.default is not dataclasses.MISSING else Empty,
default_factory=f.default_factory
if f.default_factory is not dataclasses.MISSING
Expand All @@ -72,7 +70,6 @@ def collect(cls, typ: type) -> list[Self]:
default_factory = None
field = cls(
name=f.name, # pyright: ignore
annotation=f.type, # pyright: ignore
default=default or Empty, # pyright: ignore
default_factory=default_factory or Empty, # pyright: ignore
metadata=f.metadata, # pyright: ignore
Expand Down Expand Up @@ -107,7 +104,6 @@ def collect(cls, typ: type) -> list[Self]:
)
field = cls(
name=f.name,
annotation=f.type,
default=default,
default_factory=default_factory,
)
Expand All @@ -124,11 +120,9 @@ def collect(cls, typ: type) -> list[Self]:
for param in callable_view.parameters:
name = param.name
f = typ.__fields__[name] # type: ignore
annotation = param.type_view.strip_optional().annotation

field = cls(
name=name,
annotation=annotation,
default=f.default # pyright: ignore
if f.default.__repr__() != "PydanticUndefined" # pyright: ignore
else Empty,
Expand All @@ -146,7 +140,6 @@ def collect(cls, typ: type) -> list[Self]:
for name, f in typ.model_fields.items(): # type: ignore
field = cls(
name=name, # pyright: ignore
annotation=f.annotation, # pyright: ignore
default=f.default # pyright: ignore
if f.default.__repr__() != "PydanticUndefined" # pyright: ignore
else Empty,
Expand All @@ -164,7 +157,6 @@ def collect(cls, typ: type) -> list[Self]:
for name, f in typ.__pydantic_fields__.items(): # type: ignore
field = cls(
name=name, # pyright: ignore
annotation=f.annotation, # pyright: ignore
default=f.default or Empty, # pyright: ignore
default_factory=f.default_factory or Empty, # pyright: ignore
)
Expand Down
Loading