SF.net SVN: docutils:[9903 ] trunk/docutils/docutils

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9903
          http://sourceforge.net/p/docutils/code/9903
Author:   milde
Date:     2024-08-15 07:30:39 +0000 (Thu, 15 Aug 2024)
Log Message:
-----------
Fix type hints (typing.TypeAlias is new in Python 3.12).

Modified Paths:
--------------
    trunk/docutils/docutils/nodes.py
    trunk/docutils/docutils/utils/__init__.py

Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py	2024-08-15 07:30:31 UTC (rev 9902)
+++ trunk/docutils/docutils/nodes.py	2024-08-15 07:30:39 UTC (rev 9903)
@@ -41,7 +41,12 @@
                                  Mapping, Sequence)
     from types import ModuleType
     from typing import (Any, ClassVar, Final, Literal, Self,
-                        SupportsIndex, TypeAlias, TypeVar)
+                        SupportsIndex, TypeVar)
+    if sys.version_info[:2] >= (3, 12):
+        from typing import TypeAlias
+    else:
+        from typing_extensions import TypeAlias
+
     from xml.dom import minidom
 
     from docutils.frontend import Values

Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py	2024-08-15 07:30:31 UTC (rev 9902)
+++ trunk/docutils/docutils/utils/__init__.py	2024-08-15 07:30:39 UTC (rev 9903)
@@ -28,9 +28,11 @@
 if TYPE_CHECKING:
     from collections.abc import Callable, Sequence, Iterable
     from typing import Any, Final, Literal, TextIO
+    if sys.version_info[:2] >= (3, 12):
+        from typing import TypeAlias
+    else:
+        from typing_extensions import TypeAlias
 
-    from typing_extensions import TypeAlias
-
     from docutils.nodes import Node
     from docutils.frontend import Values
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.