Conversation
New API for lowercase-only output (0-9a-z, 31 characters): - KSUID.to_base36() / KSUID.from_base36() instance/class methods - generate_lowercase() — sortable KSUID as lowercase string - generate_token_lowercase() — secure random token as lowercase string - from_base36() — module-level convenience to parse base36 strings - Full base36 encode/decode with overflow validation Also: - Fix flaky __main__ smoke test: replaced 1ms sleep (insufficient for 1-second timestamp resolution) with deterministic timestamp comparison - Extract _BASE62_STRING_LENGTH / _BASE36_STRING_LENGTH constants 49 tests passing (15 new for lowercase). https://claude.ai/code/session_01PVPVUNWhpxVa3xbDDBnwp2
- Rename __init__.py to ksuid.py for cross-platform imports (fixes Windows test failure where `from __init__ import` is invalid) - Remove sys.path.insert hacks from all files - Apply black formatting across all files - Fix all flake8 issues (unused imports, line length) - Update README to document full API: generate_lowercase(), generate_token(), generate_token_lowercase(), to_base36()/from_base36(), secure tokens, thread safety, __slots__, Python 3.9+ support https://claude.ai/code/session_01PVPVUNWhpxVa3xbDDBnwp2
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis PR adds base36 encoding support to the KSUID library, introduces new convenience functions (generate_lowercase, generate_token_lowercase, from_base36), updates import paths across the codebase to use direct ksuid module imports instead of local init paths, and significantly restructures the README documentation with table-based API reference and updated Python 3.9+ requirements. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
Windows cp1252 codepage cannot encode Unicode checkmark (U+2705) and cross mark (U+274C), causing UnicodeEncodeError on Windows CI runners. Replace all emoji in print() calls with ASCII equivalents ([+], [ok], [err]). https://claude.ai/code/session_01PVPVUNWhpxVa3xbDDBnwp2
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
example.py (1)
198-205:⚠️ Potential issue | 🟡 MinorSame Unicode emoji issue as the benchmark.py pipeline failure.
These
✅characters will causeUnicodeEncodeErroron Windows with cp1252 console encoding, just like the failing benchmark.py CI run. Consider using ASCII alternatives (e.g.,[✓]or*) here as well.Suggested fix
print("=== Summary ===") print("KSUIDs provide:") - print("✅ Sortable unique identifiers") - print("✅ Compact 27-character representation") - print("✅ URL-safe base62 encoding") - print("✅ Embedded timestamp for debugging") - print("✅ High performance and collision resistance") - print("✅ Perfect for distributed systems and databases") + print("- Sortable unique identifiers") + print("- Compact 27-character representation") + print("- URL-safe base62 encoding") + print("- Embedded timestamp for debugging") + print("- High performance and collision resistance") + print("- Perfect for distributed systems and databases")benchmark.py (1)
179-186:⚠️ Potential issue | 🔴 CriticalPipeline failure:
✅emoji causesUnicodeEncodeErroron Windows.The CI run fails here because
U+2705(✅) cannot be encoded with thecp1252codec used by the Windows console. Replace with ASCII-safe alternatives to unblock the pipeline.Suggested fix
print("=== Performance Summary ===") print("KSUID operations are highly optimized:") - print("✅ Generation: ~300k+ KSUIDs/second") - print("✅ String parsing: ~500k+ parses/second") - print("✅ Bytes parsing: ~1M+ parses/second") - print("✅ Comparison: ~10M+ comparisons/second") - print("✅ Sorting: ~500k+ items/second") - print("✅ Memory efficient: ~100 bytes per KSUID including overhead") + print("- Generation: ~300k+ KSUIDs/second") + print("- String parsing: ~500k+ parses/second") + print("- Bytes parsing: ~1M+ parses/second") + print("- Comparison: ~10M+ comparisons/second") + print("- Sorting: ~500k+ items/second") + print("- Memory efficient: ~100 bytes per KSUID including overhead")prefixed_examples.py (1)
358-386:⚠️ Potential issue | 🟡 MinorLatent Unicode issue:
✅and❌emojis will fail on Windows cp1252, same root cause as the benchmark.py pipeline failure.Consider replacing with ASCII alternatives (e.g.,
[PASS]/[FAIL],-) for consistency.
🧹 Nitpick comments (2)
prefixed_examples.py (1)
116-120: CatchValueErrorinstead of bareException, and preserve the exception chain.
from_stringonly raisesValueError, so the broadexcept Exceptioncan mask unexpected errors (e.g., aTypeErrorfrom a bug). Also,raise ... from epreserves the chain for debugging.Suggested fix
try: ksuid = from_string(ksuid_str) - return prefix, ksuid - except Exception as e: - raise ValueError(f"Invalid KSUID part: {e}") + except ValueError as e: + raise ValueError(f"Invalid KSUID part: {e}") from e + else: + return prefix, ksuidREADME.md (1)
14-15: Minor: "128 bits of randomness per second" could be clearer.This technically means "128 bits of random payload distinguish KSUIDs within the same second," but readers may misread it as a throughput metric. Consider rewording to something like "128-bit random payload" for clarity.
Summary by CodeRabbit
New Features
generate_lowercase(),generate_token_lowercase(), andfrom_base36().KSUID.to_base36()method for base36 string conversion.create_session_id()convenience function for prefixed identifiers.Documentation