# -*- coding: utf-8 -*-importtypingasTfromdatetimeimportdatetime,timezonefrom.constantsimportLATEST_VERSIONdefget_utc_now()->datetime:# pragma: no coverreturndatetime.now(timezone.utc)
[docs]defencode_version(version:T.Optional[T.Union[int,str]])->str:""" Normalize version input into standardized string format. Converts various version inputs into a consistent string representation by removing leading zeros from numeric versions while preserving the special LATEST version identifier. :param version: Version input - None, "LATEST", integer, or zero-padded string :returns: Normalized version string ("LATEST" or numeric without leading zeros) Examples:: encode_version(None) # → "LATEST" encode_version("LATEST") # → "LATEST" encode_version(1) # → "1" encode_version("000001") # → "1" encode_version(42) # → "42" """ifversionisNone:returnLATEST_VERSIONelse:returnstr(version).lstrip("0")