Skip to content

Conversation

ShaharNaveh
Copy link
Collaborator

@ShaharNaveh ShaharNaveh commented Sep 16, 2025

Closes #5732

Summary by CodeRabbit

  • New Features
    • Added a new module attribute: has_stable_extractable_node, indicating whether the platform provides a stable, extractable node identifier for UUID operations. It currently defaults to False. This allows applications to programmatically detect support and adjust behavior accordingly. No changes to existing UUID generation behavior; existing features like time-safe UUID checks remain unaffected.

Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

Walkthrough

Adds a new Python-visible boolean attribute has_stable_extractable_node to the _uuid module by exporting a constant HAS_STABLE_EXTRACTABLE_NODE = false. No other logic or control flow is changed.

Changes

Cohort / File(s) Summary
UUID module attribute export
stdlib/src/uuid.rs
Introduces constant HAS_STABLE_EXTRACTABLE_NODE: bool = false and exports it to Python as has_stable_extractable_node; existing symbols unchanged.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • youknowone

Poem

A nibble of code, a whisker’s delight,
A tiny flag set to false for now—just right.
I thump with joy, commit hops along,
In UUID fields where bytes belong.
Carrot-shaped bits, stable or not,
This bunny approves the tidy spot. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning Linked issue #5732 requests updating uuid to 3.13.3, but the provided diff shows only a single constant added to stdlib/src/uuid.rs and the PR title references "from 3.13.7", so there is no visible evidence here that the uuid dependency was bumped to 3.13.3 (or to any specific target) or that the broader upstream update was applied. Because the linked issue's primary objective is a version bump, the available changes do not demonstrate that objective has been satisfied. Please include the commits or file changes that perform the dependency/version bump (e.g., Cargo.toml/Cargo.lock or equivalent) or update the PR description to explain which upstream changes were applied and why this diff satisfies issue #5732; if the target version differs from the issue, explicitly state and justify the new target.
Title Check ❓ Inconclusive The PR title "Update uuid from 3.13.7" is related to an upstream uuid change but is ambiguous and does not describe the primary code change in the diff (the addition of HAS_STABLE_EXTRACTABLE_NODE / has_stable_extractable_node). It also conflicts with the linked issue which requested updating uuid to 3.13.3, so the title does not clearly convey the intended target or main change. Please make the title explicit and accurate (for example "Bump uuid to 3.13.7" or "stdlib: export has_stable_extractable_node in _uuid") and ensure it matches the linked issue and the actual version/dependency changes included in the PR so reviewers can quickly understand the primary change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes Check ✅ Passed The provided summary shows a single change: adding a boolean constant exported as has_stable_extractable_node inside stdlib/src/uuid.rs, which appears related to uuid behavior and does not modify unrelated files or areas of the codebase. Based on the available information there are no obvious out-of-scope changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
stdlib/src/uuid.rs (1)

11-15: Avoid redundant get_mac_address() call (minor cleanup).

The match arm discards the first result and calls get_mac_address() again; use the captured value instead.

-        match get_mac_address() {
-            Ok(Some(_ma)) => get_mac_address().unwrap().unwrap().bytes(),
+        match get_mac_address() {
+            Ok(Some(ma)) => ma.bytes(),
             // os_random is expensive, but this is only ever called once
             _ => rustpython_common::rand::os_random::<6>(),
         }
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ead821 and 216d117.

⛔ Files ignored due to path filters (2)
  • Lib/test/test_uuid.py is excluded by !Lib/**
  • Lib/uuid.py is excluded by !Lib/**
📒 Files selected for processing (1)
  • stdlib/src/uuid.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.rs: Format Rust code with the default rustfmt style (run cargo fmt)
Run clippy and fix any warnings or lints introduced by your changes
Follow Rust best practices for error handling and memory management

Files:

  • stdlib/src/uuid.rs
{vm,stdlib}/**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use RustPython macros (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust

Files:

  • stdlib/src/uuid.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (windows-2025)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (windows-2025)
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run tests under miri
🔇 Additional comments (1)
stdlib/src/uuid.rs (1)

34-35: Align HAS_STABLE_EXTRACTABLE_NODE export with existing flag style or confirm CPython expectation

has_uuid_generate_time_safe is exported as #[pyattr] fn -> u32 while HAS_STABLE_EXTRACTABLE_NODE is a const bool (stdlib/src/uuid.rs:34–35). No Python-side uses found in this repo — confirm whether CPython's stdlib uuid.py expects an int (0/1) or a bool.

If CPython expects int (0/1) — replace with fn returning u32:

-    #[pyattr(name = "has_stable_extractable_node")]
-    const HAS_STABLE_EXTRACTABLE_NODE: bool = false;
+    #[pyattr(name = "has_stable_extractable_node")]
+    fn has_stable_extractable_node(_vm: &VirtualMachine) -> u32 {
+        0
+    }

If CPython expects bool — keep as-is.

@youknowone youknowone merged commit 62067ae into RustPython:main Sep 16, 2025
12 checks passed
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.

2 participants