AssertionError? · Issue #81 · scottrogowski/code2flow · GitHub
Skip to content

AssertionError? #81

Open
Open

Description

@boyanpenkov

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.

Activity

  1. C41Underscore commented on May 4, 2023

    @C41Underscore

    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?

  2. boyanpenkov commented on May 5, 2023

    @boyanpenkov
    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
    
  3. MaudOtten commented on Sep 29, 2023

    @MaudOtten

    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.

  4. eshaanagarwal commented on May 21, 2024

    @eshaanagarwal

    Any solution to this problem ??

  5. wistuba commented on Jul 8, 2024

    @wistuba

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions