Skip to content

[DRAFT] Improve init, encode, cli #39

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 4 commits into
base: main
Choose a base branch
from

Conversation

WH-2099
Copy link

@WH-2099 WH-2099 commented May 18, 2025

Close #38

@@ -297,7 +308,9 @@ def __get_pydantic_core_schema__(cls, source: Any, handler: GetCoreSchemaHandler
core_schema.union_schema([
core_schema.is_instance_schema(ULID),
core_schema.no_info_plain_validator_function(ULID),
core_schema.str_schema(pattern=r"[A-Z0-9]{26}", min_length=26, max_length=26),
core_schema.str_schema(
pattern=rf"[{base32.ENCODE}]{{26}}", min_length=26, max_length=26
Copy link
Owner

Choose a reason for hiding this comment

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

There is a test that would need to be adapted. Good catch with the I, though.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I missed this issue and I'll follow up on a fix


@staticmethod
def _gen_bytes_from_ts(ts_ms: int | None = None) -> bytes:
"""Generate a new ULID bytes from the timestamp(ms)."""
Copy link
Owner

Choose a reason for hiding this comment

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

  1. All the other methods use the more lengthy word "timestamp" so that I would like to keep it consistent: What do you think about _bytes_from_timestamp(...)
  2. The docstring could be "Generate a ULID byte sequence of from a timestamp"

@mdomke
Copy link
Owner

mdomke commented May 20, 2025

Please execute the tests with hatch test so that you have a shorter turnaround time

@WH-2099
Copy link
Author

WH-2099 commented May 20, 2025

Ok, sorry for the misunderstanding, it's still just part of this PR (it's not a full version)
I'll finish it as soon as I can.

@WH-2099 WH-2099 changed the title Improve init, encode, cli [DRAFT] Improve init, encode, cli May 20, 2025
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.

Improve CLI interface
2 participants