From e2aec01d3185657ba011b70584f7524e36d4d2bd Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Fri, 3 Jul 2026 09:44:04 +0200 Subject: [PATCH] 0.14.0a2 fix import order, add snowflake epoch values --- CHANGELOG.md | 1 + src/suou/__init__.py | 8 ++++---- src/suou/dei.py | 2 +- src/suou/snowflake.py | 11 ++++++++++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cccb6b..03cb5b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added `ast` module * Deprecate `dei_args()` for problems with the typing system. The function is not going away tho * Module `sqlalchemy`: added `email_column()` +* Added common values for snowflake epoch in `SnowflakeEpoch` enum ## 0.13.1 and 0.12.7 diff --git a/src/suou/__init__.py b/src/suou/__init__.py index d7d1720..798fd41 100644 --- a/src/suou/__init__.py +++ b/src/suou/__init__.py @@ -16,6 +16,7 @@ This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ +from .functools import deprecated, not_implemented, timed_cache, none_pass, alru_cache, future, cooldown, do_not_flood from .iding import Siq, SiqCache, SiqType, SiqGen from .codecs import (StringCase, cb32encode, cb32decode, b32lencode, b32ldecode, b64encode, b64decode, b2048encode, b2048decode, jsonencode, twocolon_list, want_bytes, want_str, ssv_list, want_urlsafe, want_urlsafe_bytes, @@ -25,12 +26,11 @@ from .calendar import want_datetime, want_isodate, want_timestamp, age_and_days from .configparse import MissingConfigError, MissingConfigWarning, ConfigOptions, ConfigParserConfigSource, ConfigSource, DictConfigSource, ConfigValue, EnvConfigSource from .collections import TimedDict from .dei import dei_args -from .functools import deprecated, not_implemented, timed_cache, none_pass, alru_cache, future, cooldown, do_not_flood from .classtools import Wanted, Incomplete from .itertools import makelist, kwargs_prefix, ltuple, rtuple, additem, addattr from .i18n import I18n, JsonI18n, TomlI18n from .signing import UserSigner -from .snowflake import Snowflake, SnowflakeGen +from .snowflake import Snowflake, SnowflakeEpoch, SnowflakeGen from .lex import symbol_table, lex, ilex from .strtools import PrefixIdentifier from .validators import matches, not_less_than, not_greater_than, yesno, must_be @@ -41,7 +41,7 @@ from .color import OKLabColor, chalk, WebColor, RGBColor, LinearRGBColor, \ from .mat import Matrix from .argparse import LetterSubparsers -__version__ = "0.14.0a1" +__version__ = "0.14.0a2" __all__ = ( 'ColorFormatter', @@ -50,7 +50,7 @@ __all__ = ( 'LetterSubparsers', 'LinearRGBColor', 'Matrix', 'MissingConfigError', 'MissingConfigWarning', 'OKLabColor', 'OKLCHColor', 'PrefixIdentifier', 'RGBColor', - 'Siq', 'SiqCache', 'SiqGen', 'SiqType', 'Snowflake', 'SnowflakeGen', + 'Siq', 'SiqCache', 'SiqGen', 'SiqType', 'Snowflake', 'SnowflakeEpoch', 'SnowflakeGen', 'StringCase', 'TimedDict', 'TomlI18n', 'UserSigner', 'Wanted', 'WantsContentType', 'WebColor', 'XYZColor', 'addattr', 'additem', 'age_and_days', 'alru_cache', 'b2048decode', 'b2048encode', diff --git a/src/suou/dei.py b/src/suou/dei.py index a49a398..f55d17d 100644 --- a/src/suou/dei.py +++ b/src/suou/dei.py @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. from __future__ import annotations from functools import wraps -from typing import Callable, Collection, TypeVar, Any +from typing import Callable, TypeVar from . import deprecated diff --git a/src/suou/snowflake.py b/src/suou/snowflake.py index 743a703..be6aa0f 100644 --- a/src/suou/snowflake.py +++ b/src/suou/snowflake.py @@ -21,6 +21,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. from __future__ import annotations from binascii import unhexlify +import enum import os from threading import Lock import time @@ -207,7 +208,15 @@ class Snowflake(int): def __repr__(self): return f'{self.__class__.__name__}({super().__repr__()})' + +# Common epoch values. + +class SnowflakeEpoch(int, enum.Enum): + """Common epoch values.""" + JAN_1_2025 = 1735686000 + JAN_1_2020 = 1577833200 + JAN_1_2015 = 1420066800 __all__ = ( - 'Snowflake', 'SnowflakeGen' + 'Snowflake', 'SnowflakeGen', 'SnowflakeEpoch' ) \ No newline at end of file