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

For multiline return statements show more than the first line #4

Open
andy-landy opened this issue Oct 28, 2020 · 3 comments
Open

For multiline return statements show more than the first line #4

andy-landy opened this issue Oct 28, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@andy-landy
Copy link
Owner

Now only the first line in showed.

@andy-landy andy-landy added the bug Something isn't working label Oct 28, 2020
@andy-landy andy-landy changed the title Handle multiline return statements correctly For multiline return statements show more than the first line Oct 28, 2020
@alexmojaki
Copy link

The division of line into 'pieces' in https://github.com/alexmojaki/stack_data will let you do this without having to add extra lines of context for single-line statements.

@andy-landy
Copy link
Owner Author

There's a point in leaving it be though: the standard traceback printouts have only the first line the same way.

I'll look for a way to implement it with this constraints:

  • no files should be opened and read
  • no surrounding code is shown (i.e. the function), only the expression/statement
  • for cases with nested comprehensions and all only the innermost node is printed

I looked through the stack_data code and couldn't understand if there are the relevant functions or code bricks, so I'll repeat my reading. Do you think it is implementable?

@alexmojaki
Copy link

no files should be opened and read

That's fine, that's what linecache is for.

no surrounding code is shown (i.e. the function), only the expression/statement

Pieces split lines up according to statements. You can get just the main piece by providing Options(before=0, after=0).

for cases with nested comprehensions and all only the innermost node is printed

stack_data doesn't provide that, but it's a bit of a weird goal. Can you show an example and explain why you want that?

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

2 participants