From: "Michael R. Crusoe" <crusoe@debian.org>
Date: Thu, 1 Jan 2026 17:08:55 +0000
Subject: Fix circular import loop

Forwarded: https://github.com/piskvorky/smart_open/pull/834
---
 smart_open/doctools.py       | 3 ++-
 smart_open/smart_open_lib.py | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/smart_open/doctools.py b/smart_open/doctools.py
index 931f756..3d16b57 100644
--- a/smart_open/doctools.py
+++ b/smart_open/doctools.py
@@ -18,7 +18,6 @@ import os.path
 import re
 
 from . import compression
-from . import transport
 
 PLACEHOLDER = '    smart_open/doctools.py magic goes here'
 
@@ -224,6 +223,8 @@ def tweak_open_docstring(f):
 
 
 def tweak_parse_uri_docstring(f):
+    from . import transport
+
     buf = io.StringIO()
     seen = set()
     schemes = []
diff --git a/smart_open/smart_open_lib.py b/smart_open/smart_open_lib.py
index ccec7bc..da530c6 100644
--- a/smart_open/smart_open_lib.py
+++ b/smart_open/smart_open_lib.py
@@ -26,7 +26,6 @@ import smart_open.compression as so_compression
 import smart_open.utils as so_utils
 
 from smart_open import doctools
-from smart_open import transport
 
 #
 # For backwards compatibility and keeping old unit tests happy.
@@ -53,6 +52,8 @@ def _sniff_scheme(uri_as_string):
 
 
 def parse_uri(uri_as_string):
+    from smart_open import transport
+
     """
     Parse the given URI from a string.
 
@@ -337,6 +338,8 @@ def _shortcut_open(
     :returns: The opened file
     :rtype: file
     """
+    from smart_open import transport
+   
     if not isinstance(uri, str):
         return None
 
@@ -379,6 +382,8 @@ def _open_binary_stream(uri, mode, transport_params):
     :returns: A named file object
     :rtype: file-like object with a .name attribute
     """
+    from smart_open import transport
+   
     if mode not in ('rb', 'rb+', 'wb', 'wb+', 'ab', 'ab+'):
         #
         # This should really be a ValueError, but for the sake of compatibility
