Skip to content

Commit

Permalink
Disable suggester
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Aug 25, 2024
1 parent 1fba299 commit d46bbc7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
32 changes: 18 additions & 14 deletions coconut/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3493,25 +3493,30 @@ def __new__(_coconut_cls, {all_args}):

return self.assemble_data(decorators, name, namedtuple_call, inherit, extra_stmts, stmts, base_args, paramdefs)

def make_namedtuple_call(self, name, namedtuple_args, types=None):
def make_namedtuple_call(self, name, namedtuple_args, types=None, of_args=None):
"""Construct a namedtuple call."""
if types:
wrapped_types = [
self.wrap_typedef(types.get(i, "_coconut.typing.Any"), for_py_typedef=False)
for i in range(len(namedtuple_args))
]
if name is None:
return "_coconut_mk_anon_namedtuple(" + tuple_str_of(namedtuple_args, add_quotes=True) + ", " + tuple_str_of(wrapped_types) + ")"
else:
return '_coconut.typing.NamedTuple("' + name + '", [' + ", ".join(
'("' + argname + '", ' + wrapped_type + ")"
for argname, wrapped_type in zip(namedtuple_args, wrapped_types)
) + "])"
else:
if name is None:
return "_coconut_mk_anon_namedtuple(" + tuple_str_of(namedtuple_args, add_quotes=True) + ")"
else:
return '_coconut.collections.namedtuple("' + name + '", ' + tuple_str_of(namedtuple_args, add_quotes=True) + ')'
wrapped_types = None
if name is None:
return (
"_coconut_mk_anon_namedtuple("
+ tuple_str_of(namedtuple_args, add_quotes=True)
+ ("" if wrapped_types is None else ", " + tuple_str_of(wrapped_types))
+ ("" if of_args is None else ", of_args=" + tuple_str_of(of_args) + "")
+ ")"
)
elif wrapped_types is None:
return '_coconut.collections.namedtuple("' + name + '", ' + tuple_str_of(namedtuple_args, add_quotes=True) + ')' + ("" if of_args is None else tuple_str_of(of_args))
else:
return '_coconut.typing.NamedTuple("' + name + '", [' + ", ".join(
'("' + argname + '", ' + wrapped_type + ")"
for argname, wrapped_type in zip(namedtuple_args, wrapped_types)
) + "])" + ("" if of_args is None else tuple_str_of(of_args))

def assemble_data(self, decorators, name, namedtuple_call, inherit, extra_stmts, stmts, match_args, paramdefs=()):
"""Create a data class definition from the given components.
Expand Down Expand Up @@ -3617,8 +3622,7 @@ def anon_namedtuple_handle(self, original, loc, tokens):
names.append(name)
items.append(item)

namedtuple_call = self.make_namedtuple_call(None, names, types)
return namedtuple_call + "(" + ", ".join(items) + ")"
return self.make_namedtuple_call(None, names, types, of_args=items)

def single_import(self, loc, path, imp_as, type_ignore=False):
"""Generate import statements from a fully qualified import and the name to bind it to."""
Expand Down
12 changes: 6 additions & 6 deletions coconut/compiler/templates/header.py_template
Original file line number Diff line number Diff line change
Expand Up @@ -2017,17 +2017,17 @@ collectby.using_threads = _coconut_partial(_coconut_parallel_mapreduce, collectb
def _namedtuple_of(**kwargs):
"""Construct an anonymous namedtuple of the given keyword arguments."""
{namedtuple_of_implementation}
def _coconut_mk_anon_namedtuple(fields, types=None, of_kwargs=None):
def _coconut_mk_anon_namedtuple(fields, types=None, of_kwargs={empty_dict}, of_args=()):
if types is None:
NT = _coconut.collections.namedtuple("_namedtuple_of", fields)
else:
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:
nt = NT
else:
nt = NT(**of_kwargs)
{set_nt_match_args} return nt
if not (of_kwargs or of_args):
return NT
nt = NT(*of_args, **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 = not PY2
prompt_use_suggester = False

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

Expand Down

0 comments on commit d46bbc7

Please sign in to comment.