From 0a5e6a85db0345cc4150b5d78c6eff5ca4e04c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Mon, 17 Mar 2025 22:05:06 +0100 Subject: [PATCH 1/5] chore(docs): clean-up conf.py --- docs/source/conf.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 2be8ac8..a36cd9d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,7 +12,7 @@ copyright = f"{datetime.now(timezone.utc).year}, Martin Domke" author = "Martin Domke" master_doc = "index" -source_suffix = [".rst", ".md"] +source_suffix = {".rst": "restructuredtext", ".md": "restructuredtext"} # The full version, including alpha/beta/rc tags release = ulid.__version__ @@ -31,11 +31,6 @@ # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = [] - # -- Options for HTML output ------------------------------------------------- @@ -76,7 +71,6 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] pygments_style = "sphinx" autodoc_member_order = "groupwise" From d349fd3897c958bb41b67c0c2d3977ab8180a7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Mon, 17 Mar 2025 22:10:52 +0100 Subject: [PATCH 2/5] fix(docs): note unproperly used It also fixes this warning: Explicit markup ends without a blank line; unexpected unindent. --- ulid/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ulid/__init__.py b/ulid/__init__.py index 96178e3..d2e4a23 100644 --- a/ulid/__init__.py +++ b/ulid/__init__.py @@ -162,8 +162,9 @@ def from_int(cls: type[U], value: int) -> U: def parse(cls: type[U], value: Any) -> U: """Create a new :class:`ULID`-object from a given value. - .. note:: This method should only be used when the caller is trying to parse a ULID from - a value when they're unsure what format/primitive type it will be given in. + .. note:: + This method should only be used when the caller is trying to parse a ULID from + a value when they're unsure what format/primitive type it will be given in. """ if isinstance(value, ULID): return cast(U, value) From 1ec30541260f52d14cdd6b56dc97f198ac9c580f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Mon, 17 Mar 2025 22:36:32 +0100 Subject: [PATCH 3/5] fix(docs): remove invalid refs (deleted methods) --- CHANGELOG.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2487273..0b2f5fb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,7 +9,7 @@ Versions follow `Semantic Versioning `_ --------------------- Changed ~~~~~~~ -* Raise `TypeError` instead of `ValueError` if constructor is called with value of wrong type. +* Raise ``TypeError`` instead of ``ValueError`` if constructor is called with value of wrong type. * Update ``ruff`` linter rules and switch to ``hatch fmt``. Added @@ -71,7 +71,7 @@ Added ~~~~~ * Added a new flag ``--uuid4`` to the CLI ``show`` command, that converts the provided ``ULID`` into an RFC 4122 compliant ``UUID``. -* The `ulid build` command allows the use of the special value ``-`` for all options to read its +* The ``ulid build`` command allows the use of the special value ``-`` for all options to read its inputs from ``stdin``. E.g. .. code-block:: bash @@ -128,7 +128,7 @@ Changed Added ~~~~~ * Added support for Python 3.10. -* Added :attr:`__version__` variable to package. +* Added ``__version__`` variable to package. `1.0.3`_ - 2021-07-14 @@ -153,7 +153,7 @@ Added Changed ~~~~~~~ * Dropped support for Python 2. Only Python 3.6+ is supported. -* The named constructor :meth:`.ULID.new` has been removed. Use one of the specifc named +* The named constructor ``ULID.new`` has been removed. Use one of the specifc named constructors instead. For a new :class:`.ULID` created from the current timestamp use the standard constructor. @@ -169,8 +169,8 @@ Changed ulid = ULID.from_timestamp(time.time()) ulid = ULID.from_datetime(datetime.now()) -* The :meth:`.ULID.str` and :meth:`.ULID.int` methods have been removed in favour of the more - Pythonic special dunder-methods. Use `str(ulid)` and `int(ulid)` instead. +* The ``ULID.str`` and ``ULID.int`` methods have been removed in favour of the more + Pythonic special dunder-methods. Use ``str(ulid)`` and ``int(ulid)`` instead. * Added the property :meth:`.ULID.hex` that returns a hex representation of the :class:`.ULID`. .. code-block:: python From 8c791f6f8660302f3d9e91afadae78ee968c8a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Mon, 17 Mar 2025 22:49:54 +0100 Subject: [PATCH 4/5] fix(docs): intersphinx mapping --- docs/source/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index a36cd9d..a172782 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,6 +23,7 @@ # ones. extensions = [ "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", "sphinx.ext.napoleon", "sphinx.ext.viewcode", "sphinx_copybutton", @@ -74,3 +75,7 @@ pygments_style = "sphinx" autodoc_member_order = "groupwise" +# ---------------------------------------------- + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {"python": ("https://docs.python.org/3", None)} From e57b65dc22b3b5490c2922670f6f0a5b8462ab08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Mon, 17 Mar 2025 22:53:57 +0100 Subject: [PATCH 5/5] fix(docs): ref to `datetime` redirects to `ULID.datetime` instead of `datetime.datetime` from the Python stdlib --- ulid/__init__.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ulid/__init__.py b/ulid/__init__.py index d2e4a23..a6e957e 100644 --- a/ulid/__init__.py +++ b/ulid/__init__.py @@ -1,11 +1,10 @@ from __future__ import annotations +import datetime import functools import os import time import uuid -from datetime import datetime -from datetime import timezone from typing import Any from typing import cast from typing import Generic @@ -88,9 +87,9 @@ def __init__(self, value: bytes | None = None) -> None: ) @classmethod - @validate_type(datetime) - def from_datetime(cls: type[U], value: datetime) -> U: - """Create a new :class:`ULID`-object from a :class:`datetime`. The timestamp part of the + @validate_type(datetime.datetime) + def from_datetime(cls: type[U], value: datetime.datetime) -> U: + """Create a new :class:`ULID`-object from a :class:`datetime.datetime`. The timestamp part of the `ULID` will be set to the corresponding timestamp of the datetime. Examples: @@ -185,7 +184,7 @@ def parse(cls: type[U], value: Any) -> U: return cls.from_timestamp(value) if isinstance(value, float): return cls.from_timestamp(value) - if isinstance(value, datetime): + if isinstance(value, datetime.datetime): return cls.from_datetime(value) if isinstance(value, bytes): return cls.from_bytes(value) @@ -214,15 +213,15 @@ def timestamp(self) -> float: return self.milliseconds / constants.MILLISECS_IN_SECS @property - def datetime(self) -> datetime: - """Return the timestamp part as timezone-aware :class:`datetime` in UTC. + def datetime(self) -> datetime.datetime: + """Return the timestamp part as timezone-aware :class:`datetime.datetime` in UTC. Examples: >>> ulid.datetime datetime.datetime(2020, 4, 30, 14, 33, 27, 560000, tzinfo=datetime.timezone.utc) """ - return datetime.fromtimestamp(self.timestamp, timezone.utc) + return datetime.datetime.fromtimestamp(self.timestamp, datetime.timezone.utc) @property def hex(self) -> str: