Skip to content

Update uuid to uuid7#2303

Draft
auvipy wants to merge 12 commits intomainfrom
uuid
Draft

Update uuid to uuid7#2303
auvipy wants to merge 12 commits intomainfrom
uuid

Conversation

@auvipy
Copy link
Copy Markdown
Member

@auvipy auvipy commented May 28, 2025

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.20%. Comparing base (883a33c) to head (bb8dc31).
⚠️ Report is 23 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
kombu/utils/uuid.py 66.66% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2303      +/-   ##
==========================================
- Coverage   82.22%   82.20%   -0.03%     
==========================================
  Files          79       79              
  Lines       10077    10086       +9     
  Branches     1152     1154       +2     
==========================================
+ Hits         8286     8291       +5     
- Misses       1589     1592       +3     
- Partials      202      203       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread kombu/utils/uuid.py Outdated
@auvipy auvipy requested a review from Copilot May 28, 2025 09:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the UUID generation utility to support UUID version 7 while retaining support for UUID4 as a fallback option. Key changes include switching the function parameter from a Callable to a version literal and introducing a try/except block for importing uuid7 with a fallback implementation.

Comment thread kombu/utils/uuid.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@auvipy auvipy added this to the 5.7.0 milestone May 28, 2025
@auvipy
Copy link
Copy Markdown
Member Author

auvipy commented May 28, 2025

this will need tests update and thorough testing before merge

@WilliamDEdwards
Copy link
Copy Markdown

My $0.02: it should still be possible to manually specify UUID4s - to not break the case where pre-generated UUID4s are passed to signatures.

@auvipy
Copy link
Copy Markdown
Member Author

auvipy commented May 28, 2025

My $0.02: it should still be possible to manually specify UUID4s - to not break the case where pre-generated UUID4s are passed to signatures.

would you mind elaborate a bit more please? so that I can clearly understand what you wanted to be done here?

@WilliamDEdwards
Copy link
Copy Markdown

My $0.02: it should still be possible to manually specify UUID4s - to not break the case where pre-generated UUID4s are passed to signatures.

would you mind elaborate a bit more please? so that I can clearly understand what you wanted to be done here?

Sure:

This use case should not break:

import uuid

repositories.celery.infrastructure.celery_app.signature(
        result.name,
        immutable=task.immutable,
        args=result.args,
        kwargs=result.kwargs,
).set(task_id=str(uuid.uuid4()))  # <<< Notice this

@auvipy
Copy link
Copy Markdown
Member Author

auvipy commented May 28, 2025

OK, thanks a lot!

@auvipy auvipy self-assigned this May 28, 2025
Comment thread kombu/utils/uuid.py Outdated
auvipy and others added 2 commits January 22, 2026 12:49
Co-authored-by: Gert Van Gool <gertvangool@gmail.com>
@blacksmith-sh
Copy link
Copy Markdown
Contributor

blacksmith-sh Bot commented Jan 22, 2026

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
code 1/code 1 View Logs

Fix in Cursor

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (3)

kombu/utils/uuid.py:23

  • There are blank lines in the function docstring that contain trailing whitespace (between sections). Flake8 will flag these as W293 blank line contains whitespace; please remove the spaces on the blank lines in the docstring.
    """Generate a unique ID based on the specified UUID version (4 or 7).
    
    Parameters
    ----------
    version : Literal[4, 7]
        The UUID version to use for generating the unique ID. Defaults to 7.
        If UUID7 is unavailable, it falls back to UUID4 regardless of the input.
    

kombu/utils/uuid.py:8

  • The comment "Python 3.14 or later" is likely to become misleading (this project currently declares support up to Python 3.13). Suggest making the comment version-agnostic (e.g., "Python versions that include uuid7") or removing it.
    # Python 3.14 or later
    from uuid import uuid7

kombu/utils/uuid.py:19

  • New branching behavior (version selection, ValueError on invalid input, and UUID7 fallback) is introduced here, but the existing t/unit/utils/test_uuid.py tests only cover uuid() returning unique strings. Please extend tests to cover uuid(version=4), uuid(version=7), and the invalid-version error path so regressions are caught.
def uuid(version: Literal[4, 7] = 7) -> str:
    """Generate a unique ID based on the specified UUID version (4 or 7).
    
    Parameters
    ----------

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kombu/utils/uuid.py Outdated
Comment thread kombu/utils/uuid.py
Comment on lines +15 to +16
def uuid(version: Literal[4, 7] = 7) -> str:
"""Generate a unique ID based on the specified UUID version (4 or 7).
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

This changes the public uuid() API from accepting an arbitrary UUID factory callable to accepting a version integer. Since uuid is re-exported from kombu.common (and likely used externally), this is a backward-incompatible signature change. Consider preserving the previous callable-based parameter for compatibility (e.g., keep a _uuid: Callable[...] | None positional arg and make version keyword-only), or introduce a new function for UUID7 while keeping the old behavior.

Copilot uses AI. Check for mistakes.
Comment thread kombu/utils/uuid.py Outdated
Comment on lines +1 to +4
from __future__ import annotations

from typing import Callable
from uuid import UUID, uuid4
from typing import Literal
from uuid import uuid4
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The module-level docstring was removed, and this repo appears to require module docstrings (flake8-docstrings would report D100 for a public module). Please re-add the "UUID utilities." docstring at the top of the file (before the __future__ import).

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

5 participants