Skip to content

Commit

Permalink
Fix circular import loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Aug 15, 2024
1 parent 8a58abe commit d1cda5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion smart_open/doctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import re

from . import compression
from . import transport

PLACEHOLDER = ' smart_open/doctools.py magic goes here'

Expand Down Expand Up @@ -214,6 +213,8 @@ def tweak_open_docstring(f):


def tweak_parse_uri_docstring(f):
from . import transport

buf = io.StringIO()
seen = set()
schemes = []
Expand Down
7 changes: 6 additions & 1 deletion smart_open/smart_open_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d1cda5c

Please sign in to comment.