Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Variable redefinition in the same cell shows completions from previous value #15043

Copy link
Copy link
@Darshan808

Description

@Darshan808
Issue body actions

Description:

When a variable is redefined in the same cell, tab-completions still show attributes of the previous type instead of the new one.

Reproduce

In [1]: a = 1

In [2]: a = []
        a.<TAB>  # shows completions like as_integer_ratio, real, etc.

Expected behavior:

Completions should reflect the current type of the variable — in this case, list attributes such as append, extend, etc.

Cause:

In the _attr_matches function, if the object is already defined, we do not consider the lines above in the current cell.

obj = self._evaluate_expr(expr)
if obj is not_found:
if context:
# try to evaluate on full buffer
previous_lines = "\n".join(
context.full_text.split("\n")[: context.cursor_line]
)
if previous_lines:
all_code_lines_before_cursor = (
self._extract_code(previous_lines) + "\n" + expr
)
obj = self._evaluate_expr(all_code_lines_before_cursor)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.