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

AssertionError? #81

Open
boyanpenkov opened this issue Apr 29, 2023 · 5 comments
Open

AssertionError? #81

boyanpenkov opened this issue Apr 29, 2023 · 5 comments

Comments

@boyanpenkov
Copy link

has anybody seen the following AssertionError?

Traceback (most recent call last):
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/bin/code2flow", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/engine.py", line 860, in main
    code2flow(
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/engine.py", line 734, in code2flow
    file_groups, all_nodes, edges = map_it(sources, language, no_trimming,
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/engine.py", line 478, in map_it
    file_group = make_file_group(file_ast_tree, source, extension)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/engine.py", line 359, in make_file_group
    file_group.add_node(language.make_root_node(body_trees, parent=file_group), is_root=True)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/python.py", line 230, in make_root_node
    calls = make_calls(lines)
            ^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/python.py", line 54, in make_calls
    call = get_call_from_func_element(element.func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/python.py", line 18, in get_call_from_func_element
    assert type(func) in (ast.Attribute, ast.Name, ast.Subscript, ast.Call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

I'm on code2flow 2.5.1, which is the one in conda-forge.

@C41Underscore
Copy link

Are you able to provide a bit more information about how you got this error? Was this executed on a single file or a collection of them?

@boyanpenkov
Copy link
Author

@C41Underscore -- thanks!

Yes, this was executed on a collection of files (specifically, https://github.com/perrette/papers/tree/master) and the specific command is

(python311) → master Work/papers pwd                                                                                         9:55:12
/home/boyan/boyanshouse/Vazhno/Work/papers
(python311) → master Work/papers code2flow papers --language py --target-function addcmd --upstream-depth=2 --downstream-depth=10
Code2Flow: Found 11 files from sources argument.
Code2Flow: Processing 11 source file(s).
Code2Flow:   papers/__init__.py
Code2Flow:   papers/__main__.py
Code2Flow:   papers/_version.py
Code2Flow:   papers/bib.py
Code2Flow:   papers/config.py
Code2Flow:   papers/duplicate.py
Code2Flow:   papers/encoding.py
Code2Flow:   papers/extract.py
Code2Flow:   papers/filename.py
Code2Flow:   papers/latexenc.py
Code2Flow:   papers/utils.py
Traceback (most recent call last):
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/bin/code2flow", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/engine.py", line 860, in main
    code2flow(
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/engine.py", line 734, in code2flow
    file_groups, all_nodes, edges = map_it(sources, language, no_trimming,
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/engine.py", line 478, in map_it
    file_group = make_file_group(file_ast_tree, source, extension)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/engine.py", line 356, in make_file_group
    for new_node in language.make_nodes(node_tree, parent=file_group):
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/python.py", line 205, in make_nodes
    calls = make_calls(tree.body)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/python.py", line 54, in make_calls
    call = get_call_from_func_element(element.func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boyan/boyanshouse/miniconda3/envs/python311/lib/python3.11/site-packages/code2flow/python.py", line 18, in get_call_from_func_element
    assert type(func) in (ast.Attribute, ast.Name, ast.Subscript, ast.Call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

@MaudOtten
Copy link

Dear both,
I am running into the same error. It occurs when I pass a path to a main directory of python scripts, but not if I specify a single script in this directory.

@eshaanagarwal
Copy link

Any solution to this problem ??

@wistuba
Copy link

wistuba commented Jul 8, 2024

I have the same.

How to reproduce:

Python 3.11.9 (not sure this is relevant)

git clone https://github.com/astropy/astropy.git
cd astropy
code2flow astropy

I've looked into the type, one example can be ast.BinOp.

Maybe this is an uncovered case? It happens here: https://github.com/astropy/astropy/blob/main/astropy/modeling/tests/test_compound.py#L554

(poly | shift.inverse)(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants