diff --git a/smart_open/doctools.py b/smart_open/doctools.py index daa2bc01..880b9e72 100644 --- a/smart_open/doctools.py +++ b/smart_open/doctools.py @@ -18,7 +18,6 @@ import re from . import compression -from . import transport PLACEHOLDER = ' smart_open/doctools.py magic goes here' @@ -214,6 +213,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 25b12677..ef684e71 100644 --- a/smart_open/smart_open_lib.py +++ b/smart_open/smart_open_lib.py @@ -33,7 +33,6 @@ 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. @@ -77,6 +76,8 @@ def parse_uri(uri_as_string): ----- smart_open/doctools.py magic goes here """ + from smart_open import transport + scheme = _sniff_scheme(uri_as_string) submodule = transport.get_transport(scheme) as_dict = submodule.parse_uri(uri_as_string) @@ -332,6 +333,8 @@ def _shortcut_open( :returns: The opened file :rtype: file """ + from smart_open import transport + if not isinstance(uri, str): return None @@ -374,6 +377,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