Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Do not pass a data structure to a function and mutate it. #213

Merged
merged 1 commit into from
Jan 16, 2018

Conversation

mibanescu
Copy link
Member

In python, I find that passing a data structure to a function/class makes me
think the function/class has a local copy of it.

In the case of redirect_data, the parent step should "own" the data structure,
and child steps should "reach" into the parent to fetch it, instead of using
a locally stored reference. Then it's more obvious that it's a "borrowed"
data structure and its change should be visible to sibling steps.

In python, I find that passing a data structure to a function/class makes me
think the function/class has a local copy of it.

In the case of redirect_data, the parent step should "own" the data structure,
and child steps should "reach" into the parent to fetch it, instead of using
a locally stored reference. Then it's more obvious that it's a "borrowed"
data structure and its change should be visible to sibling steps.
@pulpbot
Copy link
Member

pulpbot commented Nov 17, 2017

Can one of the admins verify this patch?

1 similar comment
@pulpbot
Copy link
Member

pulpbot commented Nov 17, 2017

Can one of the admins verify this patch?

@mibanescu
Copy link
Member Author

This is just a style preference, and I'm perfectly fine if you reject the PR. But as a reader of the code, it took me longer than necessary to understand how data was flowing through the plugin.

@dkliban
Copy link
Member

dkliban commented Nov 27, 2017

I discussed with @ipanova and we would like to wait to merge this until after 2.15.0 is released.

Copy link
Member

@dkliban dkliban left a comment

Choose a reason for hiding this comment

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

Thank you!

@dkliban dkliban merged commit 1374350 into pulp:master Jan 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants