Skip to content
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

Merged
merged 4 commits into from
Sep 11, 2023

Conversation

hussein-awala
Copy link
Member


^ 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.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:core-operators Operators, Sensors and hooks within Core Airflow area:webserver Webserver related Issues labels Aug 28, 2023
@hussein-awala hussein-awala changed the title replace unacessary dict comprehension by dict() in core replace unnecessary dict comprehension by dict() in core Aug 28, 2023
@hussein-awala hussein-awala marked this pull request as draft August 28, 2023 21:42
@@ -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())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
op_kwargs: dict[str, Any] = dict(self.op_kwargs.items())
op_kwargs: dict[str, Any] = self.op_kwargs.copy()

Copy link
Member Author

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

Copy link
Member

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.

airflow/www/decorators.py Outdated Show resolved Hide resolved
airflow/models/dagrun.py Outdated Show resolved Hide resolved
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
@hussein-awala hussein-awala marked this pull request as ready for review August 30, 2023 21:40
@@ -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()}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return {"task_ids": lineage.copy()}
return {"task_ids": dict(lineage)}

Otherwise you've got a copy of defaultdict rather than dict

Copy link
Member

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?

Copy link
Member Author

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

@uranusjr uranusjr merged commit 6a33d05 into apache:main Sep 11, 2023
42 checks passed
@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.2 milestone Oct 3, 2023
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Oct 3, 2023
ephraimbuddy pushed a commit that referenced this pull request Oct 5, 2023
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
(cherry picked from commit 6a33d05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API area:core-operators Operators, Sensors and hooks within Core Airflow area:webserver Webserver related Issues type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants