question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add stdin and stdout options

See original GitHub issue

Currently autoflake reads from a file by taking a filename, and outputs a diff with a patch to make. This works well for some command line usage, but doesn’t integrate so well with replacing a buffer in Vim. This could be improved by offering an option to read the file from stdin, and an option for outputting the entire file contents, with the patch applied, to stdout. stdin support could either by via flag, or by reading a special filename -. Supposing there was a flag for stdout support, then autoflake could automatically remove unused imports in Vim with both flags like so.

silent 0,$!autoflake --stdin --output-file

That command would take the contents of the current buffer, pass it to autoflake via stdin, get the new file after applying the patch back out again, and replace the current buffer with that text.

At the moment, I shall have to save my current buffer to a file, run autoflake on that temporary file and save the diff to another temporary file, and then use the :diffpatch command to apply the patch to the current buffer, in order to integrate autoflake with Vim.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:21 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
myintcommented, Aug 15, 2022

I see. That sounds reasonable then. Welcome aboard!

1reaction
fsouzacommented, Aug 31, 2021

@myint hi there! If I were to take on this change, would you accept a patch? I can build on #37 or start from scratch, whatever works better (haven’t investigated what will be simpler yet).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add stdin and stdout options · Issue #12 · PyCQA/autoflake
Currently autoflake reads from a file by taking a filename, and outputs a diff with a patch to make. This works well for...
Read more >
What are stdin, stderr and stdout in Bash - Linux Hint
Whenever running any command in the terminal, stdin, stderr, and stdout are three data streams that bash creates. If you're familiar with the...
Read more >
Consistent way to redirect both stdin & stdout to files in python ...
sys.stdout = open(options.output, 'w') for line in fileinput.input(files): ... If you want to point it out, add it to the help strings.
Read more >
stdin, stdout, stderr - Microsoft Learn
The stdin , stdout , and stderr global constant pointers are standard streams for input, output, and error output.
Read more >
subprocess — Subprocess management — Python 3.11.1 ...
subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None, ... These options, along with all of the other options, are described in more ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found