jerryshao commented on code in PR #12715:
URL: https://github.com/apache/gravitino/pull/12715#discussion_r3901832329
##########
clients/client-python/gravitino/dto/job/job_template_dto.py:
##########
@@ -97,17 +97,25 @@ def validate(self) -> None:
raise ValueError('"executable" is required and cannot be empty')
@classmethod
- def from_json(
- cls, s: str, infer_missing: bool = False, **kwargs
+ def from_dict_by_type(
+ cls, data: Dict, infer_missing: bool = False
) -> "JobTemplateDTO":
- """Creates a JobTemplateDTO from a JSON string."""
- data = json.loads(s)
+ """Creates a JobTemplateDTO from a dict, dispatching to the concrete
subclass based
+ on the "jobType" field.
+ """
job_type = JobType.job_type_deserialize(data.get("jobType"))
subclass = JOB_TYPE_TEMPLATE_MAPPING.get(job_type)
if not subclass:
raise ValueError(f"Unsupported job type: {job_type}")
return subclass.from_dict(data, infer_missing=infer_missing)
+ @classmethod
+ def from_json(
+ cls, s: str, infer_missing: bool = False, **kwargs
+ ) -> "JobTemplateDTO":
+ """Creates a JobTemplateDTO from a JSON string."""
+ return cls.from_dict_by_type(json.loads(s),
infer_missing=infer_missing)
Review Comment:
Fixed — now forwards `**kwargs` to `json.loads(...)` instead of dropping it,
matching the base `DataClassJsonMixin.from_json` contract. (Removing the
parameter outright trips pylint's `arguments-differ` check against the base
class.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]