精华内容
下载资源
问答
  • autopep8

    2020-12-09 09:53:40
    <div><p>autopep8</p><p>该提问来源于开源项目:fooying/3102</p></div>
  • Autopep8

    2021-01-09 03:50:16
    <div><p>Let's wait for the outstaning pull requests and I'll redo this one</p><p>该提问来源于开源项目:Tribler/tribler</p></div>
  • autopep8_autopep8

    2020-12-22 22:12:07
    修正python pep8的警告挺无趣的, 用了 autopep8 感觉比较爽. 记录如下.----------------pep8检查----------------平时我用pydev做pep8检查, 最近处理的是一堆单独的python脚本, 用komodo edit做pep8检查.komodo edit...

    修正python pep8的警告挺无趣的, 用了 autopep8 感觉比较爽. 记录如下.

    ----------------

    pep8检查

    ----------------

    平时我用pydev做pep8检查, 最近处理的是一堆单独的python脚本, 用komodo edit做pep8检查.

    komodo edit安装Perfect Python插件后, 就可以按照pep8方式检查代码格式.

    ----------------

    pep8自动修复(在komodo edit中)

    ----------------

    下载和安装autopep8包后.

    komodo edit, 增加一个command, 用来自动修复当前python的pep8警告. 命令如下,

    D:\pythonenv\python272_flask\Scripts\python.exe D:\pythonenv\python272_flask\Lib\site-packages\autopep8.py --in-place --ignore=E123,E133,E501  "%F"

    ----------------

    pep8自动修复(在notepad++中)

    ----------------

    notepad++,  安装插件NppExec, 然后将如下命令加到 NppExec, F6是NppExec的快捷键.

    增加 python_pep8_fix 命令

    D:\pythonenv\python272_flask\Scripts\python.exe D:\pythonenv\python272_flask\Lib\site-packages\autopep8.py --in-place --ignore=E123,E133,E501 "$(FULL_CURRENT_PATH)"

    ----------------

    注意

    ----------------

    1. 使用autopep8修复后的文件, komodo edit和npp 都不能自动检测出该文件已经修改了, 需要手工重新加载文件.

    2. 我忽略一些不合适的检查项目, 比如行字符超过82. 所以增加如下参数:

    --ignore=E123,E133,E501

    3. 我仅仅用 autopep8 修复以一些风格问题(比如import/空格/空行问题),  其他问题不推荐自动修复, 有一点风险,  所以autopep8 --aggressive选项是不打开的.

    展开全文
  • Autopep8简介官方解释:autopep8 automatically formats Python code to conform to the PEP 8 style guide. It uses the pycodestyle utility to determine what parts of the code needs to be formatted. autopep...

    Autopep8简介

    官方解释:autopep8 automatically formats Python code to conform to the PEP 8 style guide. It uses the pycodestyle utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting issues that can be reported by pycodestyle.

    Python语言的编码遵从PEP8规范,Autopep8工具能够依据PEP8规范,快速对代码文件进行规范检查并自动排版。对于变量名,类名,函数名等,会给出提示信息,需要工程师手动修改。

    Autopep8的安装。有了pip工具,可以用命令轻松安装:

    $ pip install autopep8

    Autopep8的命令行格式运行:

    $ autopep8 --in-place --aggressive --aggressive

    在Pycharm中集成Autopep8:

    Step1:

    File -> Settings… ->Tools -> External Tools -> 点击“+”号添加

    Step2:

    在添加界面,有5处需要添加

    Name:autopep8

    Program:C:\Python27\Scripts\autopep8.exe(在python的Scripts目录下)

    Arguments:--in-place --aggressive --aggressive $FilePath$

    Working directory:$ProjectFileDir$

    Output filters:$FILE_PATH$\:$LINE$\:$COLUMN$\:.*

    配置完成后,点击OK结束。

    Step3:

    右键点击需要规范的文件,在菜单中找到External Tools -> autopep8。完成!

    规范完了之后,文件中存在一些波浪线的代码,就是需要手动修改的地方。

    上面是完全按照标准的PEP8规范进行代码格式化的。但是有一些规范,可以忽略,此时可以在Parameters中加入—ignore参数。如:

    Parameters:--in-place --aggressive --ignore=E123,E133,E50 $FilePath$

    --ignore后面的E123等就是PEP8的规范代号,具体所指的规则,可以在这里查看到:

    用户可以根据需要,添加需要忽略的规则。

    展开全文
  • autopep8_Autopep8的使用

    2020-12-22 22:12:06
    Autopep8的使用什么是Autopep8在python开发中, 大家都知道,python编码规范是PEP8,但是在市级开发中有的公司严格要求PEP8规范开发, 有的公司不会在乎那些,在我的理解中,程序员如果想走的更高,或者更远,干任何...

    Autopep8的使用

    什么是Autopep8

    在python开发中, 大家都知道,python编码规范是PEP8,但是在市级开发中有的公司严格要求PEP8规范开发, 有的公司不会在乎那些,在我的理解中,程序员如果想走的更高,或者更远,干任何事情必须得专业化(本人理解方式), 不要求很多东西都是精通,但最少得有一门精通的语言,小弟在此在大佬面前装逼了, 忘看过的大牛不要揭穿, 留下你懂的我不懂的知识,大家一起学习,一起进步。 谢谢。

    Autopep8是一个将python代码自动编排的一个工具,它使用pep8工具来决定代码中的那部分需要被排版,Autopep8可以修复大部分pep8工具中报告的排版问题。很多人都知道 Ctrl+Alt+L 也可以排版, 但是我要告诉你,快捷键只是可以简单的排版。跟Autopep8是无法相比的。

    安装Autopep8:

    pip install autopep8

    安装完成之后,import导入一下,测试是否安装成功。

    Aytopep8的使用

    安装完成之后,打开pycharm,创建一个新的python文件, demo.py 将一下代码放入文件中。

    [

    ](javascript:void(0)😉

    def example1():

    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 ('' in {'f': 2}) in {'has_key() is deprecated': True};

    class Example3(object):

    def __init__(self, bar):

    # Comments should have a space after the hash.

    if bar:

    bar += 1

    bar = bar * bar

    else:

    some_string = """

    Indentation in multiline strings should not be touched.Only actual code should be reindented.

    """

    [

    ](javascript:void(0)😉

    这几行代码看上去是不是很乱, 接下来就要使用:Autopep8模块了

    打开cmd找到demo.py的文件的上级目录,

    然后输入以下命令:

    autopep8 --in-place --aggressive --aggressive file.py

    file.py 是你的demo.py

    输入命令,按回车执行成功是不返回的, 执行完成之后就可以了,在次打开文件就可以看到变化了。

    [

    ](javascript:void(0)😉

    import math

    import sys

    def example1():

    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 ('' in {'f': 2}) in {'has_key() is deprecated': True};

    class Example3(object):

    def __init__(self, bar):

    # Comments should have a space after the hash.

    if bar:

    bar += 1

    bar = bar * bar

    else:

    some_string = """

    Indentation in multiline strings should not be touched.Only actual code should be reindented.

    """

    [

    ](javascript:void(0)😉

    执行完Autopep8之后代码是不是看上去简洁多了。

    有人会说,没写一个函数就执行一遍命令, 是不是有点麻烦啊, 是的, 有有点麻烦, 但是pycharm是可以配置的, 配置过程如下:

    1: File ---> Settings ---> Tools ---> External Tools

    打开之后,可以看见窗体左上角有一个 + 号, 点击+号添加。

    [

    ](javascript:void(0)😉

    Name: 名称可以随意

    Program: autopep8 # 前提必须先安装

    Arguments: --in-place --aggressive --aggressive $FilePath$

    Working directory: $ProjectFileDir$

    Advanced Options

    ---- Outputfilters:

    $FILE_PATH$\:$LINE$\:$COLUMN$\:.*

    [

    ](javascript:void(0)😉

    以上配置完成之后点击 OK 保存即可。

    快捷使用:

    Tools ---> External Tools ---> Autopep8 鼠标点击一下即可。

    展开全文
  • # NOTE: 安装autopep8$ pip install --upgrade autopep8# NOTE: 对文件进行格式化$ autopep8 --in-place --aggressive --aggressive 扩展阅读autopep8 automatically formats Python code to conform to the PEP 8 ...

    # NOTE: 安装autopep8

    $ pip install --upgrade autopep8

    # NOTE: 对文件进行格式化

    $ autopep8 --in-place --aggressive --aggressive

    扩展阅读

    autopep8 automatically formats Python code to conform to the PEP 8 style guide. It uses the pycodestyle utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting issues that can be reported by pycodestyle.

    autopep8 fixes the following issues reported by pycodestyle:

    E101 - Reindent all lines.

    E11 - Fix indentation. (not include E112 and E113)

    E121 - Fix indentation to be a multiple of four.

    E122 - Add absent indentation for hanging indentation.

    E123 - Align closing bracket to match opening bracket.

    E124 - Align closing bracket to match visual indentation.

    E125 - Indent to distinguish line from next logical line.

    E126 - Fix over-indented hanging indentation.

    E127 - Fix visual indentation.

    E128 - Fix visual indentation.

    E20 - Remove extraneous whitespace.

    E211 - Remove extraneous whitespace.

    E22 - Fix extraneous whitespace around keywords.

    E224 - Remove extraneous whitespace around operator.

    E226 - Fix missing whitespace around arithmetic operator.

    E227 - Fix missing whitespace around bitwise/shift operator.

    E228 - Fix missing whitespace around modulo operator.

    E231 - Add missing whitespace.

    E241 - Fix extraneous whitespace around keywords.

    E242 - Remove extraneous whitespace around operator.

    E251 - Remove whitespace around parameter '=' sign.

    E26 - Fix spacing after comment hash for inline comments.

    E265 - Fix spacing after comment hash for block comments.

    E27 - Fix extraneous whitespace around keywords.

    E301 - Add missing blank line.

    E302 - Add missing 2 blank lines.

    E303 - Remove extra blank lines.

    E304 - Remove blank line following function decorator.

    E306 - Expected 1 blank line before a nested definition

    E401 - Put imports on separate lines.

    E501 - Try to make lines fit within --max-line-length characters.

    E502 - Remove extraneous escape of newline.

    E701 - Put colon-separated compound statement on separate lines.

    E70 - Put semicolon-separated compound statement on separate lines.

    E711 - Fix comparison with None.

    E712 - Fix comparison with boolean.

    E721 - Use "isinstance()" instead of comparing types directly.

    E722 - Fix bare except.

    W291 - Remove trailing whitespace.

    W292 - Add a single newline at the end of the file.

    W293 - Remove trailing whitespace on blank line.

    W391 - Remove trailing blank lines.

    W601 - Use "in" rather than "has_key()".

    W602 - Fix deprecated form of raising exception.

    W603 - Use "!=" instead of "<>"

    W604 - Use "repr()" instead of backticks.

    W690 - Fix various deprecated code (via lib2to3).

    autopep8 also fixes some issues not found by pycodestyle.

    Correct deprecated or non-idiomatic Python code (via lib2to3). Use this for making Python 2.6 and 2.7 code more compatible with Python 3. (This is triggered if W690 is enabled.)

    Normalize files with mixed line endings.

    Put a blank line between a class docstring and its first method declaration. (Enabled with E301.)

    Remove blank lines between a function declaration and its docstring. (Enabled with E303.)

    autopep8 avoids fixing some issues found by pycodestyle.

    E112/E113 for non comments are reports of bad indentation that break syntax rules. These should not be modified at all.

    E265, which refers to spacing after comment hash, is ignored if the comment looks like code. autopep8 avoids modifying these since they are not real comments. If you really want to get rid of the pycodestyle warning, consider just removing the commented-out code. (This can be automated via eradicate.)

    展开全文
  • MAC在PyCharm配置Autopep8为什么要配置autopep8?PEP8 是 Python 官方推出的一套编码的规范。只要我们的代码不符合它的规范,就会有相应的提示。可以让代码自动的格式化。配置步骤:一. 在终端中安装Autopep8:sudo pip...
  • 关于PEP 8PEP 8,Style Guide for ...关于Autopep8Autopep8是自动将Python代码格式化为符合PEP 8风格的工具。它使用pycodestyle工具来确定代码的哪些部分需要被格式化。Autopep8能够修复大部分pycodestyle检测的格式...
  • mac autopep8

    2019-05-06 14:56:12
    命令行 autopep8 --in-place --aggressive --aggressive <filename> pycharm Tools-External Tools 2.运行时提示permission denied 原因:autopep8.py这个文件没有执行权限 解决办法:chmod 755 ...
  • autopep8 integration

    2020-12-08 23:25:37
    <div><p>autopep8 is a code quality tool that ensure coherent and clean coding style. <p>This is a minimal integration of the tool. At this point, it's mainly adjusting spaces and tabs. <p>The ...
  • Run autopep8 formatter

    2020-12-28 00:33:59
    <div><p>Ran <code>autopep8 --in-place --recursive .</code> to format with <code>autopep8 Side note: should there be a step in Travis/Github actions to automatically do this? (see ...
  • autopep8 problem

    2020-12-01 15:16:38
    <ol><li>Install autopep8</li><li>Open Autopep8 plugins in Jupyter-Notebook</li><li>Open Spyder</li></ol> <p><strong>What is the expected output? What do you see instead?</strong></p> <p>I don't ...
  • autopep8 plugin?

    2020-12-01 11:26:37
    <div><p>Would an autopep8 plugin be additive? <p>The advantage of autopep8 over yapf is that autopep8 is far more conservative - it only changes code where there's a linting error, and so easier ...
  • pycharm安装autopep8

    2020-08-21 11:16:48
    pycharm安装autopep8 一、命令提示符窗口执行 pip install autopep8 二、打开File–Settings–Tools-External Tools,然后点击左上角的+ 三、 为这个工具命名 program的位置写你Autopep8安装位置 Arguments:–in-...
  • PyCharm 配置AutoPEP8

    2018-11-06 14:31:04
    1. 安装 AutoPEP8 打开 终端 | cmd pip install autopep8 2. PyCharm 配置 AutoPEP8 File → Settings → Tools → External Tools → 点击加号 Name: AutoPEP8 (随意) Program: autopep8 Arguments: --in-...
  • Pycharm 安装 autopep8

    2019-12-03 17:35:58
    Pycharm 安装 autopep8 打开电脑cmd,输入 pip install autopep8 回车 ok 坐等下载安装完成即可 将autopep8配置到Pycharm中 打开Pycharm→File→settings→Tools→Extends Tools→添加 a:Name:Autopep8(可以随便...
  • 我尝试使用autopep8格式化某些python代码,期望除其他事项外,分隔超过80个字符的注释行.我使用了这个测试文件test.py,它仅包含注释:#asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf ...
  • Autopep8的使用

    千次阅读 2019-07-16 10:59:15
    什么是Autopep8 在python开发中, 大家都知道,python编码规范是PEP8,但是在市级开发中有的公司严格要求PEP8规范开发, 有的公司不会在乎那些,在我的理解中,程序员如果想走的更高,或者更远,干任何事情必须得...
  • pycharm配置autopep8

    2018-07-19 11:33:06
    1.安装autopep8 pip install autopep8 2.pycharm配置autopep8 1.打开perference 2.tools-&amp;gt;Extends Tools-+ Name:Autopep8(可以随便取) Tools settings: - Programs:`autopep8` ...
  • python autopep8

    2016-12-01 10:39:00
     使用pip install autopep8或easy_install 都可以。 使用  autopep8 -i -a 要检查的py文件路径  更多参数使用可以参考:https://github.com/hhatto/autopep8/ 转载于:...
  • Use autopep8.

    2020-12-09 04:38:16
    <div><p>Hi, <p>I like pep8, and pylint....s a good idea to use autopep8 to all python files before analyse with pylint.</p><p>该提问来源于开源项目:sebdah/git-pylint-commit-hook</p></div>

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 983
精华内容 393
关键字:

autopep8