Questions tagged [autopep8]

autopep8 automatically formats Python code to conform to the PEP 8 style guide.

99 questions
0
votes
1 answer

Why does my python formatter add blank lines before and after function definitions?

My code is automatically formatted by the formatter, and it adds blank lines that I do not want. This happens while using both autopep8 and black. This is my code: dict_n = {} def new_dash(): new_list = input("do something ").split(",") for…
Babul 7154
  • 61
  • 2
  • 9
0
votes
0 answers

VSCode: Settings.Json and Autopep8 Not Working

Can anyone share their VSCode autopep8 settings.json? Every month or so I get "there is no formatter installed for 'python' files installed" Preferably for WSL2 and a conda environment! My settings are as follows: { "python.formatting.provider":…
John Stud
  • 1,506
  • 23
  • 46
0
votes
0 answers

How to disable autopep8 rule for entire file?

Say, I want to format following python file with autopep8: ## Double '#' at the start of this line will be removed due to E265/E266 # extra space after '=' will be removed due to E222 a = 1 But I want to ignore E265/E266 rules for entire file…
infi
  • 13
  • 3
0
votes
1 answer

Autopep8 not appearing in Command Palette in VS Code despite being installed and accessible in the terminal

In VS Code, I have installed autopep8 and verified that the path is correct. I can use autopep8 in the terminal without any issues. However, when I search for the "python run" item in the Command Palette, I see all the other options from the…
Martin
  • 46
  • 9
0
votes
0 answers

autopep 8 does not fix lengthy lists and dictionaries

Following the example, https://pypi.org/project/autopep8/ I tried to run autopep8 on the example file. I ran autopep8 -i test.py. Also tried aggressive options and --select=E501. It does not fix the line length of the dictionary in the example…
Mikhail Genkin
  • 3,247
  • 4
  • 27
  • 47
0
votes
0 answers

Is there a standard way to write on top of each python file which pycodestyle errors and warnings are ignored?

I have a python file and I have disabled some pycodestyles errors(in the code editor) like pycodestyle: error E501 - line too long (111 > 79 characters) Is there a standard way to add this info in the python file itself in the beginning as a comment…
john wick
  • 73
  • 9
0
votes
1 answer

Eclipse + Pydev + pylint + pep8 - can't get the editor to ignore E501 errors

I'd like to be able to either increase the max linelength or tell the code formatting checkers to ignore E501. Previous solutions are very old, but more importantly, do not work for me. I just installed eclipse: Version: 2022-06 (4.24.0) Build id:…
Tom Mozdzen
  • 338
  • 4
  • 16
0
votes
1 answer

How do I make autopep8 allow a comment at the end of a line?

I'm trying to format my code with autopep8 (because this appears to be the default one in VSCode). But there is a problem with it: I am using a lib that doesn't care about typing, so I need to suffix some lines with # type:ignore to make the linter…
birgersp
  • 3,909
  • 8
  • 39
  • 79
0
votes
1 answer

Undo shorter line-length when formatting Python code

I accidentally ran Black without --line-length. My company uses a line-length of 110. Now all of the code has been formatted to 80. How can I undo this? Running black --line-length 110 has no effect. Cheers.
Minsky
  • 473
  • 2
  • 7
  • 18
0
votes
1 answer

Are there any flags for autopep8 (vscode), to allow multiple import in the same line?

I know that you can pass "python.formatting.autopep8Args": ["--max-line-length=200"] in .vscode/settings.json to override the max 79 length for a line, are there any flags for allow multiple line imports. What I want: import json, os, h5py,…
Kanishk
  • 258
  • 1
  • 3
  • 9
0
votes
0 answers

VS code python formatter not working(autopep8, black, yapf)

I am using VS Code 1.60 on macbook pro, Big Sur 11.4 with python 3.9.7. I have installed Python(Microsoft) extension for formatting. Before installing it, syntax errors were not highlighted. After installation, highlights with red lines. But,…
주피터
  • 135
  • 6
0
votes
3 answers

autopep8 indenting inconsistently

I'm implementing autopep8 into an existing project and sometimes longer lines are being formatting weirdly. For example, there is this code snippet: client_data={'id': str(self.user.client.client_id), 'type': self.user.client.client_type}, which is…
Reimus Klinsman
  • 898
  • 2
  • 12
  • 23
0
votes
1 answer

How to setup VS Code for formatting line breaking symmetrically for Python?

Original code job.create_common_job_log_line(message=message, model_id=model_id, product_id=product.id) This is how it formatted my code which is extremely ugly job.create_common_job_log_line( …
tom10271
  • 4,222
  • 5
  • 33
  • 62
0
votes
0 answers

Makefile use global script

i'm fairly new to using Makefiles to write commands for me. I have made a Makefile to run and format a Flask app. The contents are run: .\venv\Scripts\python.exe app.py format: prettier -w .\templates\ prettier -w .\static\ autopep8…
user15032172
  • 55
  • 1
  • 6
0
votes
1 answer

How to stop autopep from indenting line after backslash?

autopep8 converts this code sum_of_two_numbers = first \ + second to this sum_of_two_numbers = first \ + second Is it a bug? If so, is it a bug in pycodestyle or autopep8? Are there any error codes I can ignore to prevent…
Waska
  • 1
  • 1