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

Assertion tracebacks too verbose #200

Open
wimglenn opened this issue Sep 20, 2024 · 0 comments
Open

Assertion tracebacks too verbose #200

wimglenn opened this issue Sep 20, 2024 · 0 comments

Comments

@wimglenn
Copy link

For an example like this:

FOO = "{}"
foo = FOO.format("foo")

The output of flynt -v is too verbose:

$ flynt example.py -v
Running flynt v.1.0.1
Using following options: Namespace(verbose=True, quiet=False, no_multiline=False, line_length=88, dry_run=False, stdout=False, string=False, transform_percent=True, transform_format=True, transform_concats=False, transform_joins=False, fail_on_change=False, aggressive=False, exclude=None, src=['example.py'], version=False)
Exception during conversion of code: Traceback (most recent call last):
  File "/tmp/f/.venv/lib/python3.12/site-packages/flynt/transform/transform.py", line 32, in transform_chunk
    converted, changed = fstringify_node(
                         ^^^^^^^^^^^^^^^^
  File "/tmp/f/.venv/lib/python3.12/site-packages/flynt/transform/FstringifyTransformer.py", line 88, in fstringify_node
    result = ft.visit(node)
             ^^^^^^^^^^^^^^
  File "/jump/software/rhel8/Python-3.12.6/lib/python3.12/ast.py", line 407, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "/tmp/f/.venv/lib/python3.12/site-packages/flynt/transform/FstringifyTransformer.py", line 31, in visit_Call
    result_node = joined_string(
                  ^^^^^^^^^^^^^^
  File "/tmp/f/.venv/lib/python3.12/site-packages/flynt/transform/format_call_transforms.py", line 18, in joined_string
    assert isinstance(fmt_call.func, ast.Attribute) and isinstance(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
Traceback (most recent call last):
  File "/tmp/f/.venv/lib/python3.12/site-packages/flynt/transform/transform.py", line 32, in transform_chunk
    converted, changed = fstringify_node(
                         ^^^^^^^^^^^^^^^^
  File "/tmp/f/.venv/lib/python3.12/site-packages/flynt/transform/FstringifyTransformer.py", line 88, in fstringify_node
    result = ft.visit(node)
             ^^^^^^^^^^^^^^
  File "/jump/software/rhel8/Python-3.12.6/lib/python3.12/ast.py", line 407, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "/tmp/f/.venv/lib/python3.12/site-packages/flynt/transform/FstringifyTransformer.py", line 31, in visit_Call
    result_node = joined_string(
                  ^^^^^^^^^^^^^^
  File "/tmp/f/.venv/lib/python3.12/site-packages/flynt/transform/format_call_transforms.py", line 18, in joined_string
    assert isinstance(fmt_call.func, ast.Attribute) and isinstance(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
fstringifying /tmp/f/example.py...no change

Flynt run has finished. Stats:

Execution time:                            0.001s
Files checked:                             1
Files modified:                            0

_-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_._-_.
Please run your tests before committing. Did flynt get a perfect conversion? give it a star at: 
~ https://github.com/ikamensh/flynt ~
Thank you for using flynt. Upgrade more projects and recommend it to your colleagues!

It is normal/expected that flynt shouldn't rewrite this kind of example. Could the AssertionError traceback be hidden under an additional verbosity flag, e.g. -vv?

When formatting a large codebase, I like to see the messages about where flynt was not aggressive enough or not able to transform some code, but it's hard to see the forest for the trees when there are so many of these assertion tracebacks.

Thanks!

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

1 participant