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

Instanciate new empty lists for each instance of WorkflowRepoManager #415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mgoerens
Copy link
Contributor

Previously we were assigning values to attributes on the class level. For list in particular, this had the side effect of leaking values between instances:

>>> m = OwnersFileSubmissionsE2ETest()
>>> m.repo_manager._WorkflowRepoManager__local_branches_created
['e2e-owners-d376dfa-6d3820eb5c624ddc9066f96f1a69640e']
>>> m.cleanup()
>>> m.repo_manager._WorkflowRepoManager__local_branches_created
[]
>>> m = OwnersFileSubmissionsE2ETest()
>>> m.repo_manager._WorkflowRepoManager__local_branches_created
['e2e-owners-d376dfa-6d3820eb5c624ddc9066f96f1a69640e', 'e2e-owners-d376dfa-cc7f8acf1850498cb6c758bc286f2bec']

Using a dataclass for WorkflowRepoManager, we can ensure that empty lists are initialized for each new instance, and attributes values remain independant.

Fix #414

@mgoerens mgoerens changed the title Instanciate new empty lists for each instance Instanciate new empty lists for each instance of WorkflowRepoManager Dec 16, 2024
This was referenced Dec 16, 2024
Previously we were assigning values to attributes on the class level.
For list in particular, this had the side effect of leaking values
between instances:

```
>>> m = OwnersFileSubmissionsE2ETest()
>>> m.repo_manager._WorkflowRepoManager__local_branches_created
['e2e-owners-d376dfa-6d3820eb5c624ddc9066f96f1a69640e']
>>> m.cleanup()
>>> m.repo_manager._WorkflowRepoManager__local_branches_created
[]
>>> m = OwnersFileSubmissionsE2ETest()
>>> m.repo_manager._WorkflowRepoManager__local_branches_created
['e2e-owners-d376dfa-6d3820eb5c624ddc9066f96f1a69640e', 'e2e-owners-d376dfa-cc7f8acf1850498cb6c758bc286f2bec']
```

Using a dataclass for WorkflowRepoManager, we can ensure that empty
lists are initialized for each new instance, and attributes values
remain independant.

Fix openshift-helm-charts#414

Signed-off-by: Matthias Goerens <[email protected]>
This was referenced Dec 20, 2024
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.

Not found warning when deleting local branches and worktree
1 participant