Skip to content

Commit

Permalink
Fix #438 util and pkio were circular imports (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
robnagler authored Feb 1, 2024
1 parent e39fce3 commit 9ed6d52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions pykern/pkio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:license: http://www.apache.org/licenses/LICENSE-2.0.html
"""

# Root module: Limit imports to avoid dependency issues
# Root module: Limit imports to avoid dependency issues
from pykern import pkconst
from pykern import pkinspect
import contextlib
Expand All @@ -15,7 +15,6 @@
import os
import os.path
import py
import pykern.util
import random
import re
import shutil
Expand Down Expand Up @@ -139,9 +138,11 @@ def is_pure_text(filepath, test_size=512):
Returns:
bool: True if file is likely pure text, false if likely binary
"""
from pykern import util

with open(filepath, "rb") as f:
b = f.read(test_size + 1)
return pykern.util.is_pure_text(b[:test_size], is_truncated=len(b) > test_size)
return util.is_pure_text(b[:test_size], is_truncated=len(b) > test_size)


def mkdir_parent(path):
Expand Down
8 changes: 4 additions & 4 deletions pykern/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
:copyright: Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
:license: http://www.apache.org/licenses/LICENSE-2.0.html
"""
from pykern import pkconfig
from pykern import pkinspect
from pykern import pkio
from pykern.pkdebug import pkdc, pkdexc, pkdlog, pkdp
# Root module: Limit imports to avoid dependency issues
import os.path
import sys

Expand All @@ -26,6 +23,8 @@ def cfg_absolute_dir(value):
Returns:
py.path.Local absolute path to dir
"""
from pykern import pkio, pkconfig

if not os.path.isabs(value):
pkconfig.raise_error("must be absolute")
if not os.path.isdir(value):
Expand All @@ -48,6 +47,7 @@ def dev_run_dir(package_object):
Raises:
AssertionError: Raised when not in development mode
"""
from pykern import pkio, pkconfig, pkinspect

def _check_dev_files(root):
"""Check for files that only exist in development"""
Expand Down

0 comments on commit 9ed6d52

Please sign in to comment.