Skip to content

bug:Mutable Default Set Argument #329

@Roaimkhan

Description

@Roaimkhan

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 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 👍

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions