Skip to content

Removed None initialization from response#312

Open
Sirsho1997 wants to merge 2 commits into
mainfrom
feature-none-init
Open

Removed None initialization from response#312
Sirsho1997 wants to merge 2 commits into
mainfrom
feature-none-init

Conversation

@Sirsho1997

Copy link
Copy Markdown
Collaborator

Fixed

  • instantiateDataclass now skips null and blank string values from API payloads instead of passing them through as explicit None or ""
  • instantiateDataclass fills missing required str fields with "" when the API leaves them out, so dataclasses like IModel can keep version: str and architecture: str as required fields

Changed

  • Response dataclasses built via instantiateDataclass / instantiateDataclassList (IModel, IImage, IVideo, I3d, etc.) use a compact repr that omits unset, None, blank string, and empty additional_fields values

@Sirsho1997 Sirsho1997 requested a review from Copilot June 12, 2026 11:54
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include coderabbit-review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f34893f8-b303-4ff1-96d3-f7d1c844fe74

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feature-none-init

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates runware.utils.instantiateDataclass to make response dataclass construction more tolerant of incomplete/empty API payloads, and introduces a compact repr for response dataclasses to reduce noise when debugging.

Changes:

  • Add _compact_dataclass_repr and apply it to dataclasses instantiated via instantiateDataclass.
  • Skip null and blank-string values from API payloads during dataclass instantiation.
  • Auto-fill missing required str fields with "" when the payload omits them.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread runware/utils.py
Comment thread runware/utils.py
Comment thread runware/utils.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread runware/utils.py
Comment on lines +917 to 918
if k not in valid_fields or v is None:
continue
Comment thread runware/utils.py
Comment on lines +1001 to 1003
if is_dataclass(dataclass_type) and dataclass_type.__repr__ is not _compact_dataclass_repr:
dataclass_type.__repr__ = _compact_dataclass_repr
return dataclass_type(**filtered_data)
Comment thread runware/utils.py
Comment on lines 903 to 1003
@@ -898,11 +914,7 @@ def instantiateDataclass(dataclass_type: Type[Any], data: dict) -> Any:
filtered_data = {}

for k, v in data.items():
if k not in valid_fields:
continue

if v is None:
filtered_data[k] = None
if k not in valid_fields or v is None:
continue

field_type = hints.get(k)
@@ -975,7 +987,19 @@ def instantiateDataclass(dataclass_type: Type[Any], data: dict) -> Any:
filtered_data[k] = field_type(v)
else:
filtered_data[k] = v


for f in fields(dataclass_type):
if (
f.name in filtered_data
or f.default is not MISSING
or f.default_factory is not MISSING
):
continue
if hints.get(f.name) is str:
filtered_data[f.name] = ""

if is_dataclass(dataclass_type) and dataclass_type.__repr__ is not _compact_dataclass_repr:
dataclass_type.__repr__ = _compact_dataclass_repr
return dataclass_type(**filtered_data)
@Sirsho1997 Sirsho1997 changed the title Removed None initialization into response Removed None initialization from response Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants