Skip to content

Refactor tags/branches data to use dataclass instead of dicts (fixes #7798) #12364

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

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

Conversation

akumar-9686
Copy link

Description

This PR refactors the handling of tags and branches data throughout the codebase to use a dataclass (VersionData) instead of plain dictionaries. This improves type safety, code readability, and reduces the risk of bugs related to key typos or inconsistent data structures.

Key Changes

Introduced a VersionData dataclass to represent tags and branches data (identifier and verbose_name).
Updated all code that creates, passes, or consumes tags/branches data to use the dataclass instead of dictionaries.
Before passing tags/branches data to Celery tasks, the dataclasses are serialized to dicts; inside the Celery task, they are deserialized back to dataclasses.
Updated all validation and utility functions to use dataclass attributes.
Ensured full compatibility with Celery serialization.

Motivation

Previously, tags and branches were passed as lists of dictionaries, which was error-prone and harder to maintain. Using a dataclass provides a clear contract for the data structure and makes the codebase more robust.

Related Issue
Fixes #7798

How to Test

Run the test suite to ensure all affected code paths work as expected.
Trigger any Celery tasks that use tags/branches data to confirm serialization works correctly.

@akumar-9686 akumar-9686 requested a review from a team as a code owner July 28, 2025 08:35
@akumar-9686 akumar-9686 requested a review from stsewd July 28, 2025 08:35
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.

Use a named tuple for tags and branches data
1 participant