Skip to content

Commit

Permalink
Fix py2 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Aug 21, 2024
1 parent dd52a7e commit b17742d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion coconut/command/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def prompt(self, msg):
pygments.styles.get_style_by_name(self.style),
),
completer=self.get_completer(),
auto_suggest=self.suggester,
auto_suggest=self.suggester or None,
)


Expand Down
8 changes: 8 additions & 0 deletions coconut/compiler/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,14 @@ def recursive_iterator(*args, **kwargs):
''',
indent=1,
),
set_nt_match_args=pycondition(
(3, 10),
if_lt=r'''
nt.__match_args__ = nt._fields
''',
indent=1,
newline=True,
),
import_copyreg=pycondition(
(3,),
if_lt="import copy_reg as copyreg",
Expand Down
6 changes: 4 additions & 2 deletions coconut/compiler/templates/header.py_template
Original file line number Diff line number Diff line change
Expand Up @@ -2024,8 +2024,10 @@ def _coconut_mk_anon_namedtuple(fields, types=None, of_kwargs=None):
NT = _coconut.typing.NamedTuple("_namedtuple_of", [(f, t) for f, t in _coconut.zip(fields, types)])
_coconut.copyreg.pickle(NT, lambda nt: (_coconut_mk_anon_namedtuple, (nt._fields, types, nt._asdict())))
if of_kwargs is None:
return NT
return NT(**of_kwargs)
nt = NT
else:
nt = NT(**of_kwargs)
{set_nt_match_args} return nt
def _coconut_ndim(arr):
arr_mod = _coconut_get_base_module(arr)
if (arr_mod in _coconut.numpy_modules or _coconut.hasattr(arr.__class__, "__matconcat__")) and _coconut.hasattr(arr, "ndim"):
Expand Down
2 changes: 1 addition & 1 deletion coconut/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def get_path_env_var(env_var, default):
prompt_vi_mode = get_bool_env_var(vi_mode_env_var, False)
prompt_wrap_lines = True
prompt_history_search = True
prompt_use_suggester = False
prompt_use_suggester = not PY2

base_dir = os.path.dirname(os.path.abspath(fixpath(__file__)))

Expand Down

0 comments on commit b17742d

Please sign in to comment.