kubeflow / kubeflow/sdk

bug:Mutable Default Set Argument

Open
#329 1 comment 2 reactions 0 assignees View on GitHub
kind/bug needs-triage
Dominant language
Python
Stars
148
Forks
262
Avg merge
1d 2h
Merged PRs (30d)
1

Description

### What happened?

There are multiple instances in the codebase where wait_for_job_status implementations use a mutable set literal as a default argument:
```

def wait_for_job_status(
self,
name: str,
status: set[str] = {constants.TRAINJOB_COMPLETE}, # ← mutable default
...
```

### What did you expect to happen?

The parameter should default to None, with the real value assigned inside the function body:

```
def wait_for_job_status(
self,
name: str,
status: set[str] | None = None,
...
) -> types.TrainJob:
if status is None:
status = {constants.TRAINJOB_COMPLETE}
```
This is the [canonical Python pattern](https://docs.python.org/3/faq/programming.html#why-are-default-values-shared-between-objects) for mutable defaults and ensures each call gets a fresh, independent set.

### Environment

nil

### Impacted by this bug?

Give it a 👍 We prioritize the issues with most 👍

Contributor guide

Open the contributing guide

Research direction

Search the codebase for every wait_for_job_status implementation and inspect each mutable set default. Update the affected signatures and function bodies so the default is None and a fresh completion-status set is assigned inside the function; done means no such mutable defaults remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.