Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Call' object has no attribute 'value' #16

Closed
simonw opened this issue Jun 19, 2023 · 3 comments
Closed

AttributeError: 'Call' object has no attribute 'value' #16

simonw opened this issue Jun 19, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@simonw
Copy link
Owner

simonw commented Jun 19, 2023

Thanks to this issue:

I can now run symbex '*' -s in REALLY big directories, which is a great way to stress test it.

Got this:

# File: /Users/simon/Dropbox/Development/library-of-congress/.venv/lib/python3.6/site-packages/test/completion/pep0484_basic.py Line: 100
class SelfReference

Traceback (most recent call last):
  File "/Users/simon/.local/share/virtualenvs/symbex--e1aIHUb/bin/symbex", line 33, in <module>
    sys.exit(load_entry_point('symbex', 'console_scripts', 'symbex')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.local/share/virtualenvs/symbex--e1aIHUb/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.local/share/virtualenvs/symbex--e1aIHUb/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/simon/.local/share/virtualenvs/symbex--e1aIHUb/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.local/share/virtualenvs/symbex--e1aIHUb/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Dropbox/Development/symbex/symbex/cli.py", line 105, in cli
    snippet, line_no = code_for_node(code, node, class_name, signatures)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Dropbox/Development/symbex/symbex/lib.py", line 41, in code_for_node
    definition, lineno = function_definition(node), node.lineno
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Dropbox/Development/symbex/symbex/lib.py", line 150, in function_definition
    elif function_node.returns.value is None:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Call' object has no attribute 'value'
@simonw simonw added the bug Something isn't working label Jun 19, 2023
@simonw
Copy link
Owner Author

simonw commented Jun 19, 2023

In the debugger:

python -i $(which symbex) '*' -s
(Pdb) function_node.__dict__
{'name': 'function_with_non_pep_0484_annotation',
'args': <ast.arguments object at 0x1034f97e0>,
'body': [<ast.Expr object at 0x1034f91e0>, <ast.Expr object at 0x1034f8e20>, <ast.Expr object at 0x1034fa830>, <ast.Expr object at 0x1034fadd0>, <ast.Expr object at 0x1034f8790>],
'decorator_list': [],
'returns': <ast.Call object at 0x1034f87f0>,
'type_comment': None,
'lineno': 115,
'col_offset': 0,
'end_lineno': 134,
'end_col_offset': 6}

I bounced up the stack a few times and found this:

def function_with_non_pep_0484_annotation(
        x: "I can put anything here",
        xx: "",
        yy: "\r\n\0;+*&^564835(---^&*34",
        y: 3 + 3,
        zz: float) -> int("42"):
    # infers int from function call
    #? int()
    x
    # infers int from function call
    #? int()
    xx
    # infers int from function call
    #? int()
    yy
    # infers str from function call
    #? str()
    y
    #? float()
    zz
#?

Looks like that's from the Jedi test suite: https://github.com/davidhalter/jedi/blob/3699ba0aa7efd1c18e366804a2fd82e242f54231/test/completion/pep0484_basic.py#L113

@simonw
Copy link
Owner Author

simonw commented Jun 19, 2023

Since this is such an edge case I'm going to turn it into a -> ? in the output.

@simonw
Copy link
Owner Author

simonw commented Jun 19, 2023

% symbex function_with_non_pep_0484_annotation -s -f tests/example_symbols.py 
# File: tests/example_symbols.py Line: 94
def function_with_non_pep_0484_annotation(x, xx, yy, y, zz: float) -> ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant