-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace unnecessary dict comprehension by dict() in core #33858
Conversation
airflow/operators/python.py
Outdated
@@ -421,7 +421,7 @@ def __deepcopy__(self, memo): | |||
return super().__deepcopy__(memo) | |||
|
|||
def _execute_python_callable_in_subprocess(self, python_path: Path, tmp_dir: Path): | |||
op_kwargs: dict[str, Any] = {k: v for k, v in self.op_kwargs.items()} | |||
op_kwargs: dict[str, Any] = dict(self.op_kwargs.items()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
op_kwargs: dict[str, Any] = dict(self.op_kwargs.items()) | |
op_kwargs: dict[str, Any] = self.op_kwargs.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
op_kwargs type is Mapping
that doesn't have copy()
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then dict(self.op_kwargs)
should work, I think.
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
@@ -49,4 +49,4 @@ def get_lineage( | |||
for meta in outlets: | |||
lineage[meta.task_id]["outlets"] = meta.value | |||
|
|||
return {"task_ids": {k: v for k, v in lineage.items()}} | |||
return {"task_ids": lineage.copy()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return {"task_ids": lineage.copy()} | |
return {"task_ids": dict(lineage)} |
Otherwise you've got a copy of defaultdict
rather than dict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t think that’d be problematic though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @Taragolis, I should avoid any change in the values in this refactor PR
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> (cherry picked from commit 6a33d05)
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.