Closed DeadPool3333 closed 2 years ago
I am trying this but it is not formatting at all, and also if I use command line without --in-place
also it is showing non-formatted code only. Idk what I am doing wrong :/
@DeadPool3333 It's working fine in my environment. (with Linux, Python3.7.9, autopep8 1.6.0)
$ cat main.py
import math, sys;
def example1():
####This is a long comment. This should be wrapped to fit within 72 characters.
some_tuple=( 1,2, 3,'a' );
some_variable={'long':'Long code lines should be wrapped within 79 characters.',
'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'],
'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1,
20,300,40000,500000000,60000000000000000]}}
return (some_tuple, some_variable)
def example2(): return {'has_key() is deprecated':True}.has_key({'f':2}.has_key(''));
class Example3( object ):
def __init__ ( self, bar ):
#Comments should have a space after the hash.
if bar : bar+=1; bar=bar* bar ; return bar
else:
some_string = """
Indentation in multiline strings should not be touched.
Only actual code should be reindented.
"""
return (sys.path, some_string)
$ /home/ec2-user/.virtualenvs/py379crypto/bin/autopep8 --in-place main.py
$ cat main.py
import math
import sys
def example1():
# This is a long comment. This should be wrapped to fit within 72 characters.
some_tuple = (1, 2, 3, 'a')
some_variable = {'long': 'Long code lines should be wrapped within 79 characters.',
'other': [math.pi, 100, 200, 300, 9876543210, 'This is a long string that goes on'],
'more': {'inner': 'This whole logical line should be wrapped.', some_tuple: [1,
20, 300, 40000, 500000000, 60000000000000000]}}
return (some_tuple, some_variable)
def example2(): return {'has_key() is deprecated': True}.has_key(
{'f': 2}.has_key(''))
class Example3(object):
def __init__(self, bar):
# Comments should have a space after the hash.
if bar:
bar += 1
bar = bar * bar
return bar
else:
some_string = """
Indentation in multiline strings should not be touched.
Only actual code should be reindented.
"""
return (sys.path, some_string)
Could you share the following results with us?
autopep8 -vvv -d main.py
autopep8 -vvv --in-place main.py
Oh, and i tried that both commands but they are also not working yet, i mean they are also not formatting. It is just showing this
autopep8 -vvv -d main.py
:
enable config: section=pycodestyle, key=ignore, value=E, W
[file:main.py]
---> 0 issue(s) to fix {}
autopep8 -vvv --in-place main.py
enable config: section=pycodestyle, key=ignore, value=E, W
[file:main.py]
---> 0 issue(s) to fix {}
this config is ignore all errors and warnings. key=ignore, value=E, W
Could you please review the configuration file on your environment?
So actually at first i tried without config so when it dint work then i used this in my pyproject.toml
file https://github.com/hhatto/autopep8#pyproject-toml. But after that also it is not working.
Do you have any of the following files in your project?
autopep8 will read and use the settings in the pep8
or pycodestyle
or flake8
sections of the following files if they exist.
setup.cfg
tox.ini
.pep8
.flake8
No i dint have any of the file. So should i create that files? if yes than what should i enter in that files?
Yeah it is not formatting but not like this https://github.com/hhatto/autopep8#usage. My result:
import math
import sys
def example1():
# This is a long comment. This should be wrapped to fit within 72 characters.
some_tuple = (1, 2, 3, 'a')
some_variable = {'long': 'Long code lines should be wrapped within 79 characters.',
'other': [math.pi, 100, 200, 300, 9876543210, 'This is a long string that goes on'],
'more': {'inner': 'This whole logical line should be wrapped.', some_tuple: [1,
20, 300, 40000, 500000000, 60000000000000000]}}
return (some_tuple, some_variable)
def example2(): return {'has_key() is deprecated': True}.has_key({'f': 2}.has_key(''))
class Example3(object):
def __init__(self, bar):
# Comments should have a space after the hash.
if bar:
bar += 1
bar = bar * bar
return bar
else:
some_string = """
Indentation in multiline strings should not be touched.
Only actual code should be reindented.
"""
return (sys.path, some_string)
Python Code
Just used the example given in
README.md
Command Line and Configuration
.pep8
,setup.cfg
, ...Command Line
Your Environment