From fcf47d78b0142911aed5802578c5de7079fec221 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Fri, 4 Jul 2025 14:51:29 -0600 Subject: [PATCH] Version 1.1.0 - Made compatible with Python 3.8 (uses 3.10 typing from __future__) - Made uuid7.time() also verify variant, to more reliably reject invalid UUIDs - Changed repository names and links to uuid7-standard to match the package name --- pyproject.toml | 8 ++++---- uuid7.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bf20797..6cade56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ [project] name = "uuid7-standard" -version = "1.0.0" +version = "1.1.0" description = "UUIDv7 with the final standard. Not to be confused with the uuid7 package on pypi, based on a draft version that was very different." readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.8" dependencies = [] authors = [ {name = "Leo Vasanko"}, @@ -20,8 +20,8 @@ classifiers = [ ] [project.urls] -Homepage = "https://git.zi.fi/leo/uuid7-python" -Repository = "https://github.com/LeoVasanko/uuid7-python" +Homepage = "https://git.zi.fi/LeoVasanko/uuid7-standard" +Repository = "https://github.com/LeoVasanko/uuid7-standard" [build-system] requires = ["hatchling"] diff --git a/uuid7.py b/uuid7.py index 149682d..531b599 100644 --- a/uuid7.py +++ b/uuid7.py @@ -1,3 +1,4 @@ +from __future__ import annotations from datetime import datetime from datetime import timezone as _tz from secrets import token_bytes as _token_bytes @@ -28,7 +29,7 @@ def time(u: UUID | str) -> datetime: """ if not isinstance(u, UUID): u = UUID(u) - if u.version != 7: + if u.version != 7 or u.variant != "specified in RFC 4122": raise ValueError("Not a UUIDv7") ts = int.from_bytes(u.bytes[:6], "big") return datetime.fromtimestamp(ts / 1000, tz=_tz.utc)