Skip to content

Make HASH/HASHXOF types immutable#7131

Merged
youknowone merged 1 commit intoRustPython:mainfrom
moreal:fix/fail-hashlib-test_readonly_types
Feb 14, 2026
Merged

Make HASH/HASHXOF types immutable#7131
youknowone merged 1 commit intoRustPython:mainfrom
moreal:fix/fail-hashlib-test_readonly_types

Conversation

@moreal
Copy link
Contributor

@moreal moreal commented Feb 14, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved type safety for hash operations by marking core hash-related types as immutable, ensuring data integrity and preventing unintended modifications.

@moreal moreal self-assigned this Feb 14, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

The changes add IMMUTABLETYPE flags to PyHasher and PyHasherXof class definitions in the hashlib module, marking them as immutable types. No behavioral or functional modifications are introduced; only class attribute flags are updated.

Changes

Cohort / File(s) Summary
Hashlib Type Immutability
crates/stdlib/src/hashlib.rs
Added IMMUTABLETYPE flag to PyHasher and PyHasherXof class definitions to mark them as immutable types.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested reviewers

  • youknowone

Poem

🐰 Two hashes now wear crowns of stone,
Immutable, forever known,
No changing their crystalline ways,
Forever locked in Python's maze!

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (8 files):

⚔️ Lib/test/test_class.py (content)
⚔️ Lib/test/test_codecs.py (content)
⚔️ Lib/test/test_descr.py (content)
⚔️ Lib/test/test_hashlib.py (content)
⚔️ Lib/test/test_itertools.py (content)
⚔️ Lib/test/test_pickle.py (content)
⚔️ crates/stdlib/src/hashlib.rs (content)
⚔️ crates/vm/src/builtins/object.rs (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change: adding IMMUTABLETYPE flags to PyHasher and PyHasherXof classes to mark them as immutable types.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/fail-hashlib-test_readonly_types
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉


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.

@github-actions
Copy link
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[ ] lib: cpython/Lib/hashlib.py
[ ] test: cpython/Lib/test/test_hashlib.py (TODO: 9)

dependencies:

  • hashlib

dependent tests: (15 tests)

  • hashlib: test_hashlib test_hmac test_smtplib test_tarfile test_unicodedata test_urllib2_localnet
    • urllib.request: test_http_cookiejar test_pathlib test_pydoc test_site test_ssl test_urllib test_urllib2 test_urllib2net test_urllibnet

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@moreal moreal marked this pull request as ready for review February 14, 2026 11:14
@youknowone youknowone merged commit 2a20860 into RustPython:main Feb 14, 2026
14 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