autopyre
autopep8 ๊ณผ pycodestyle ์ ๊ฐ์ ํ Python Code Style Formatter
- autopyre๋ python ์ฝ๋๋ฅผ ์๋์ผ๋ก PEP8 ์คํ์ผ ๊ฐ์ด๋์ ๋ง๊ฒ ํฌ๋งคํ ํ๋ ๋๊ตฌ์ ๋๋ค.
- ํ์ด์ฌ ์ฝ๋ ์คํ์ผ ๊ฐ์ด๋ PEP8 ์ ๊ธฐ๋ฐํ ์ฝ๋ ์คํ์ผ๋ก ์์ ํด์ค๋๋ค.
- ์ฌ์ฉ์๊ฐ ์คํ์ผ ์ค์ ์ด ๊ฐ๋ฅํ๋๋ก
์ปค์คํฐ๋ง์ด์ง
๊ธฐ๋ฅ์ ์ถ๊ฐํด ์ ์ฐ์ฑ์ ๊ฐํํ์ต๋๋ค. - ๋ํ PEP8์์ ์ธ๊ธํ๋ ํด๋์ค๋ช
, ํจ์๋ช
์ ๋ํ
์๋ช ์ปจ๋ฒค์
์ ๋ถํฉํ๊ฒ ๊ตฌํํ์์ต๋๋ค.
Contents
Installation
$ pip install autopyre
$ pip install --upgrade autopyre
Requirements
autopyre requires pyrestyle
$ pip install pyrestyle
$ pip install --upgrade pyrestyle
Usage
ํ์ผ ๋ณ๊ฒฝ ๋ด์ฉ์ ์ฝ์๋ก ์ถ๋ ฅ (default):
$ autopyre -a -a -a <filename>
ํ์ผ ๋ณ๊ฒฝ ๋ด์ฉ์ ํ์ผ์ ๋ฎ์ด์ฐ๊ธฐ (aggressive level 3):
$ autopyre --in-place -a -a -a <filename>
autopyre ์คํ ์ ์ฝ๋ (์ฝ๋์ ์๋ฏธ X, ํฌ๋งคํ ์ ์ง์ค)
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,5,6000000]}}
return (some_tuple, some_variable)
def ExampleTwo(): # inline comment
return {'has_key() is deprecated':True}.has_key({'f':2}.has_key(''));
class example_three( object ): # inline comment2
def __init__ ( self, bar ):
#Comments should have a space after the hash.
if bar : bar+=1; bar=bar* bar ; return bar # ์ธ๋ผ์ธ ์ฃผ์
else:
some_string = '''
์ฌ๋ฌ ์ค ๋ฌธ์์ด
double quote ๋ณํ'''
return (sys.path, some_string)
autopyre ์คํ ํ ์ฝ๋
$ autopyre -a -a -a test_all.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,
5,
6000000]}}
return (some_tuple, some_variable)
# inline comment
def example_two():
return {"has_key() is deprecated": True}.has_key({"f": 2}.has_key(""))
# inline comment2
class ExampleThree(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 = """
์ฌ๋ฌ ์ค ๋ฌธ์์ด
double quote ๋ณํ"""
return (sys.path, some_string)
Options:
usage: autopyre [--customize] [-a -a -a] [โ-alias] [--aggressive --aggressive --aggressive] [-a -a -a --in-place] [-a -a -a --alias --in-place] [-d] [--diff] [-i] [--in-place] Automatically formats Python code to conform to the PEP 8 style guide. positional arguments: files files to format or '-' for standard in optional arguments: -i, --in-place make changes to files in place -a, --aggressive enable non-whitespace changes; multiple -a result in more aggressive changes -d, --diff show difference before formatting and after formatting --experimental enable experimental fixes --customize customzie formatting style with modifying custom.txt file
Features
autopyre fixes the following issues reported by pyrestyle:
E267 - Remove inline comment and add block comment W705 - Modify class name to capwords case W706 - Modify class name to capwords case and add aliasing code W707 - Modify function name to snake case W708 - Modify function name to snake case and add aliasing code w744 - Modify single quote to double quote w745 - Modify triple single quote to triple double quote
Naming Convention
Description:
* [-a -a -a] PEP8 ์คํ์ผ ๊ฐ์ด๋์์ ๊ถ์ฅํ๋ ํด๋์ค์ ํจ์์ ์๋ช ๊ท์น์ ๋ฐ๋ฅด์ง ์์ ๊ฒฝ์ฐ ๊ถ์ฅํ๋ ์คํ์ผ์ ๋ง๊ฒ ์์ ํฉ๋๋ค. ์์ $ autopyre -a -a -a input.py * [--alias] Aliasing ์ฝ๋ ์ฝ์ ์์ $ autopyre -a -a -a --alias input.py
Customize
Description:
* [--customize] custom.txt ํ์ผ์ ์์ ํด์ ์ ์ฉํ ์ ์์ต๋๋ค. ์์ autopyre --customize input.py
License
MIT ๋ผ์ด์ ์ค๋ฅผ ์ค์ํ๋ฉฐ LICENSE ์์ ์์ธํ ์ ๋ณด๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
Contacts
- ๊น์์ฑ github โ 2019112083@dgu.ac.kr
- ๊นํ์ฑ github โ davis0625@dgu.ac.kr
- ์ด์ ํธ github โ 2019111998@dgu.ac.kr
- ์กฐ์์ค github โ c68254@dgu.ac.kr
- ์ฐจ์ฌ์ github โ 2019112003@dgu.ac.kr
- ํ์ง์ github โ 2021111937@dgu.ac.kr