一图看懂 autopep8 模块:自动格式化Python代码,以使其符合PEP8规范,资料整理+笔记(大全)

autopep8是一个Python模块,用于自动格式化Python代码,使其遵循PEP8编码规范。它提供了各种修复函数,针对不同的PEP8错误代码,例如缩进、空格使用和行长度等。此外,它还与其他Python库如argparse、difflib和codecs等交互,以支持文件读写和文本处理。
摘要由CSDN通过智能技术生成

本文由 大侠(AhcaoZhu)原创,转载请声明。
链接: https://blog.csdn.net/Ahcao2008

Alt

一图看懂 autopep8 模块:自动格式化Python代码,以使其符合PEP8规范,资料整理+笔记(大全)

🧊摘要

  • 全文介绍python的 autopep8 模块(自动格式化Python代码,以使其符合PEP8规范)、函数、类及类的方法和属性。
  • 它通过代码抓取并经AI智能翻译和人工校对。
  • 是一部不可多得的权威字典类工具书。它是系列集的一部分。后续陆续发布、敬请关注。【原创:AhcaoZhu大侠】

🧊模块图

autopep8-module

autopep8
	◆argparse
	◆difflib
	◆locale
	◆signal
	◆token

🧊类关系图

autopep8-class

◆object
	autopep8.Atom
	autopep8.CachedTokenizer
	autopep8.Container
		autopep8.DictOrSet
		autopep8.IfExpression
		autopep8.List
		autopep8.ListComprehension
		autopep8.Tuple
	autopep8.FixPEP8
	autopep8.LineEndingWrapper
	autopep8.ReformattedLines
	autopep8.Reindenter
	◆tuple
		autopep8.Token

🧊模块全展开

☘️【autopep8】

autopep8, fullname=autopep8, file=autopep8.py

自动格式化Python代码以符合PEP 8风格指南。
只需要做一次的修复可以通过在这个模块中添加一个形式为"fix_<code>(source)"的函数来添加。
它们应该返回固定的源代码。这些修复由 apply_global_fixes() 获取。
依赖于 pycodestyle 的修复应该作为方法添加到 FixPEP8。
有关更多信息,请参阅类文档。

🔵统计

序号类别数量
1int6
4str11
5tuple2
8dict2
9module21
10class15
11function85
13residual19
14system9
15private24
16all161

🔵常量

🌿int

1 EXIT_CODE_OK 0
2 EXIT_CODE_ERROR 1
3 EXIT_CODE_EXISTS_DIFF 2
4 EXIT_CODE_ARGPARSE_ERROR 99
5 DEFAULT_INDENT_SIZE 4
6 MAX_PYTHON_FILE_DETECTION_BYTES 1024

🌿str

7 CR
8 LF
9 CRLF
10 DEFAULT_IGNORE E226,E24,W50,W690
11 DEFAULT_CONFIG C:\Users\ahcao.pep8

🌿tuple

12 CONFLICTING_CODES (‘W503’, ‘W504’)
13 PROJECT_CONFIG (‘setup.cfg’, ‘tox.ini’, ‘.pep8’, ‘.flake8’)

🌿dict

14 CODE_TO_2TO3 {‘E231’: [‘ws_comma’], ‘E721’: [‘idioms’], ‘W690’: [‘apply’, ‘except’, ‘exitfunc’, ‘numliterals’, ‘operator’, ‘paren’, '…

🔵模块

🌿15 argparse

argparse, fullname=argparse, file=argparse.py

🌿16 codecs

codecs, fullname=codecs, file=codecs.py

🌿17 collections

collections, fullname=collections, file=collections_init_.py

🌿18 copy

copy, fullname=copy, file=copy.py

🌿19 difflib

difflib, fullname=difflib, file=difflib.py

🌿20 fnmatch

fnmatch, fullname=fnmatch, file=fnmatch.py

🌿21 inspect

inspect, fullname=inspect, file=inspect.py

🌿22 io

io, fullname=io, file=io.py

🌿23 itertools

itertools, fullname=itertools, file=

🌿24 keyword

keyword, fullname=keyword, file=keyword.py

🌿25 locale

locale, fullname=locale, file=locale.py

🌿26 os

os, fullname=os, file=os.py

🌿27 re

re, fullname=re, file=re.py

🌿28 signal

signal, fullname=signal, file=signal.py

🌿29 sys

sys, fullname=sys, file=

🌿30 textwrap

textwrap, fullname=textwrap, file=textwrap.py

🌿31 token

token, fullname=token, file=token.py

🌿32 tokenize

tokenize, fullname=tokenize, file=tokenize.py

🌿33 warnings

warnings, fullname=warnings, file=warnings.py

🌿34 ast

ast, fullname=ast, file=ast.py

🌿35 pycodestyle

pycodestyle, fullname=pycodestyle, file=pycodestyle.py

🔵函数

🌿36 open_with_encoding(filename, mode=‘r’, encoding=None, limit_byte_check=-1)

open_with_encoding(filename, mode=‘r’, encoding=None, limit_byte_check=-1), module=autopep8, line:169 at site-packages\autopep8.py

返回具有特定编码的打开文件。

🌿37 detect_encoding(filename, limit_byte_check=-1)

detect_encoding(filename, limit_byte_check=-1), module=autopep8, line:178 at site-packages\autopep8.py

返回文件编码。

🌿38 readlines_from_file(filename)

readlines_from_file(filename), module=autopep8, line:193 at site-packages\autopep8.py

返回文件的内容。

🌿39 extended_blank_lines(logical_line, blank_lines, blank_before, indent_level, previous_logical)

extended_blank_lines(logical_line, blank_lines, blank_before, indent_level, previous_logical), module=autopep8, line:199 at site-packages\autopep8.py

检查类声明后是否缺少空行。

🌿40 continued_indentation(logical_line, tokens, indent_level, hang_closing, indent_char, noqa)

continued_indentation(logical_line, tokens, indent_level, hang_closing, indent_char, noqa), module=autopep8, line:223 at site-packages\autopep8.py

重写pycodestyle的函数以提供缩进信息。

🌿41 get_module_imports_on_top_of_file(source, import_line_index)

get_module_imports_on_top_of_file(source, import_line_index), module=autopep8, line:1440 at site-packages\autopep8.py

返回import 或者 从关键字位置
    举例:
      > 0: import sys
        1: import os
        2:
        3: def function():

🌿42 get_index_offset_contents(result, source)

get_index_offset_contents(result, source), module=autopep8, line:1525 at site-packages\autopep8.py

返回 (line_index, column_offset, line_contents)

🌿43 get_fixed_long_line(target, previous_line, original, indent_word=’ ', max_line_length=79, aggressive=False, experimental=False, verbose=False)

get_fixed_long_line(target, previous_line, original, indent_word=’ ', max_line_length=79, aggressive=False, experimental=False, verbose=False), module=autopep8, line:1533 at site-packages\autopep8.py

分割长行并返回结果。
    为此,可以生成多个重新格式化的候选项,然后对候选项进行排序,以启发式地选择最佳选项。

🌿44 longest_line_length(code)

longest_line_length(code), module=autopep8, line:1581 at site-packages\autopep8.py

返回最长行的长度。

🌿45 join_logical_line(logical_line)

join_logical_line(logical_line), module=autopep8, line:1588 at site-packages\autopep8.py

根据逻辑行输入返回单行。

🌿46 untokenize_without_newlines(tokens)

untokenize_without_newlines(tokens), module=autopep8, line:1596 at site-packages\autopep8.py

基于令牌返回源代码。

🌿47 _find_logical(source_lines)

_find_logical(source_lines), module=autopep8, line:1624 at site-packages\autopep8.py

🌿48 _get_logical(source_lines, result, logical_start, logical_end)

_get_logical(source_lines, result, logical_start, logical_end), module=autopep8, line:1650 at site-packages\autopep8.py

返回与结果对应的逻辑行。假设输入已经是E702-clean。

🌿49 get_item(items, index, default=None)

get_item(items, index, default=None), module=autopep8, line:1673 at site-packages\autopep8.py

🌿50 reindent(source, indent_size, leave_tabs=False)

reindent(source, indent_size, leave_tabs=False), module=autopep8, line:1680 at site-packages\autopep8.py

重新缩进所有行。

🌿51 code_almost_equal(a, b)

code_almost_equal(a, b), module=autopep8, line:1686 at site-packages\autopep8.py

如果代码相似则返回True。在比较特定行时忽略空白。

🌿52 split_and_strip_non_empty_lines(text)

split_and_strip_non_empty_lines(text), module=autopep8, line:1705 at site-packages\autopep8.py

返回以换行符分隔的行。忽略空行。

🌿53 refactor(source, fixer_names, ignore=None, filename=‘’)

refactor(source, fixer_names, ignore=None, filename=‘’), module=autopep8, line:1714 at site-packages\autopep8.py

使用lib2to3返回重构的代码。如果在重构的代码中产生忽略字符串,则跳过。

🌿54 code_to_2to3(select, ignore, where=‘’, verbose=False)

code_to_2to3(select, ignore, where=‘’, verbose=False), module=autopep8, line:1747 at site-packages\autopep8.py

🌿55 fix_2to3(source, aggressive=True, select=None, ignore=None, filename=‘’, where=‘global’, verbose=False)

fix_2to3(source, aggressive=True, select=None, ignore=None, filename=‘’, where=‘global’, verbose=False), module=autopep8, line:1759 at site-packages\autopep8.py

修复各种不推荐的代码(通过lib2to3)。

🌿56 find_newline(source)

find_newline(source), module=autopep8, line:1777 at site-packages\autopep8.py

返回源中使用的换行符类型。输入是一个行列表。

🌿57 _get_indentword(source)

_get_indentword(source), module=autopep8, line:1797 at site-packages\autopep8.py

返回缩进类型。

🌿58 _get_indentation(line)

_get_indentation(line), module=autopep8, line:1810 at site-packages\autopep8.py

返回前导空格。

🌿59 get_diff_text(old, new, filename)

get_diff_text(old, new, filename), module=autopep8, line:1819 at site-packages\autopep8.py

返回统一的新旧差异文本。

🌿60 _priority_key(pep8_result)

_priority_key(pep8_result), module=autopep8, line:1839 at site-packages\autopep8.py

排序PEP8结果的关键字。
应该首先进行全局修复。这对于缩进很重要。

🌿61 shorten_line(tokens, source, indentation, indent_word, max_line_length, aggressive=False, experimental=False, previous_line=‘’)

shorten_line(tokens, source, indentation, indent_word, max_line_length, aggressive=False, experimental=False, previous_line=‘’), module=autopep8, line:1874 at site-packages\autopep8.py

在OPERATOR处单独行。将产生多名候选。

🌿62 _shorten_line(tokens, source, indentation, indent_word, aggressive=False, previous_line=‘’)

_shorten_line(tokens, source, indentation, indent_word, aggressive=False, previous_line=‘’), module=autopep8, line:1912 at site-packages\autopep8.py

在OPERATOR处单独行。
除了多行字符串内部和末尾,输入应该没有换行符。将产生多名候选人。

🌿63 _is_binary_operator(token_type, text)

_is_binary_operator(token_type, text), module=autopep8, line:1981 at site-packages\autopep8.py

🌿64 _parse_container(tokens, index, for_or_if=None)

_parse_container(tokens, index, for_or_if=None), module=autopep8, line:2633 at site-packages\autopep8.py

解析高级容器,如列表、元组等。

🌿65 _parse_tokens(tokens)

_parse_tokens(tokens), module=autopep8, line:2692 at site-packages\autopep8.py

解析令牌。
这将令牌转换成一种更容易操作的形式。

🌿66 _reflow_lines(parsed_tokens, indentation, max_line_length, start_on_prefix_line)

_reflow_lines(parsed_tokens, indentation, max_line_length, start_on_prefix_line), module=autopep8, line:2725 at site-packages\autopep8.py

重新绘制线条,使其看起来更漂亮。

🌿67 _shorten_line_at_tokens_new(tokens, source, indentation, max_line_length)

_shorten_line_at_tokens_new(tokens, source, indentation, max_line_length), module=autopep8, line:2767 at site-packages\autopep8.py

考虑到线的长度,缩短线。
    除了多行字符串内部和末尾,输入应该没有换行符。

🌿68 _shorten_line_at_tokens(tokens, source, indentation, indent_word, key_token_strings, aggressive)

_shorten_line_at_tokens(tokens, source, indentation, indent_word, key_token_strings, aggressive), module=autopep8, line:2795 at site-packages\autopep8.py

通过在键令牌字符串中截断令牌来分隔行。
    除了多行字符串内部和末尾,输入应该没有换行符。

🌿69 token_offsets(tokens)

token_offsets(tokens), module=autopep8, line:2874 at site-packages\autopep8.py

产生令牌和偏移量。

🌿70 normalize_multiline(line)

normalize_multiline(line), module=autopep8, line:2905 at site-packages\autopep8.py

规范化会导致语法错误的多行相关代码。这是为了检查语法。

🌿71 fix_whitespace(line, offset, replacement)

fix_whitespace(line, offset, replacement), module=autopep8, line:2925 at site-packages\autopep8.py

替换偏移处的空白并返回固定行。

🌿72 _execute_pep8(pep8_options, source)

_execute_pep8(pep8_options, source), module=autopep8, line:2936 at site-packages\autopep8.py

通过python方法调用执行pycodestyle。

🌿73 _remove_leading_and_normalize(line, with_rstrip=True)

_remove_leading_and_normalize(line, with_rstrip=True), module=autopep8, line:2974 at site-packages\autopep8.py

🌿74 _reindent_stats(tokens)

_reindent_stats(tokens), module=autopep8, line:3113 at site-packages\autopep8.py

返回(lineno, indentlevel)对的列表。
    每个stmt和注释行对应一个。对于注释行,Indentlevel为-1,作为tokenize不知道如何处理它们的信号;的确,他们让我们头疼!

🌿75 _leading_space_count(line)

_leading_space_count(line), module=autopep8, line:3164 at site-packages\autopep8.py

返回行中前导空格的数目。

🌿76 refactor_with_2to3(source_text, fixer_names, filename=‘’)

refactor_with_2to3(source_text, fixer_names, filename=‘’), module=autopep8, line:3172 at site-packages\autopep8.py

使用lib2to3重构源代码。返回重构的源代码。

🌿77 check_syntax(code)

check_syntax(code), module=autopep8, line:3190 at site-packages\autopep8.py

如果语法正确,返回True。

🌿78 find_with_line_numbers(pattern, contents)

find_with_line_numbers(pattern, contents), module=autopep8, line:3198 at site-packages\autopep8.py

're.finditer'的包装器,用于查找行号。返回在内容中找到模式的行号列表。

🌿79 get_disabled_ranges(source)

get_disabled_ranges(source), module=autopep8, line:3231 at site-packages\autopep8.py

返回表示禁用范围的元组列表。如果禁用且没有重新启用,则将禁用文件的其余部分。

🌿80 filter_disabled_results(result, disabled_ranges)

filter_disabled_results(result, disabled_ranges), module=autopep8, line:3265 at site-packages\autopep8.py

根据禁用范围的元组过滤出报告。

🌿81 filter_results(source, results, aggressive)

filter_results(source, results, aggressive), module=autopep8, line:3276 at site-packages\autopep8.py

从pycodestyle中过滤掉虚假报告。如果aggressive为True,我们允许可能不安全的修复(E711, E712)。

🌿82 multiline_string_lines(source, include_docstrings=False)

multiline_string_lines(source, include_docstrings=False), module=autopep8, line:3346 at site-packages\autopep8.py

返回多行字符串中的行号。行号以1为索引。文档字符串将被忽略。

🌿83 commented_out_code_lines(source)

commented_out_code_lines(source), module=autopep8, line:3378 at site-packages\autopep8.py

返回可能是代码的注释行号。
    注释掉的代码是不好的做法,但是修改它只会增加更多的混乱。

🌿84 shorten_comment(line, max_line_length, last_comment=False)

shorten_comment(line, max_line_length, last_comment=False), module=autopep8, line:3417 at site-packages\autopep8.py

返回经过修剪或分割的长注释行。
    如果后面没有注释,则进行文本换行。对所有注释进行这种换行通常会导致注释文本参差不齐。

🌿85 normalize_line_endings(lines, newline)

normalize_line_endings(lines, newline), module=autopep8, line:3452 at site-packages\autopep8.py

返回固定行结尾。所有行将被修改为使用最常用的行结束。

🌿86 mutual_startswith(a, b)

mutual_startswith(a, b), module=autopep8, line:3463 at site-packages\autopep8.py

🌿87 code_match(code, select, ignore)

code_match(code, select, ignore), module=autopep8, line:3467 at site-packages\autopep8.py

🌿88 fix_code(source, options=None, encoding=None, apply_config=False)

fix_code(source, options=None, encoding=None, apply_config=False), module=autopep8, line:3484 at site-packages\autopep8.py

返回固定的源代码。如果"source"是字节串,"encoding"将用于解码"source"。
"```
### 🌿89 _get_options(raw_options, apply_config)
> _get_options(raw_options, apply_config), module=autopep8, line:3509 at site-packages\autopep8.py

返回解析后的选项。

### 🌿90 fix_lines(source_lines, options, filename='')
> fix_lines(source_lines, options, filename=''), module=autopep8, line:3533 at site-packages\autopep8.py

返回固定的源代码。

### 🌿91 fix_file(filename, options=None, output=None, apply_config=False)
> fix_file(filename, options=None, output=None, apply_config=False), module=autopep8, line:3575 at site-packages\autopep8.py
### 🌿92 global_fixes()
> global_fixes(), module=autopep8, line:3622 at site-packages\autopep8.py

产生多个(代码,函数)元组。

### 🌿93 _get_parameters(function)
> _get_parameters(function), module=autopep8, line:3635 at site-packages\autopep8.py
### 🌿94 apply_global_fixes(source, options, where='global', filename='', codes=None)
> apply_global_fixes(source, options, where='global', filename='', codes=None), module=autopep8, line:3649 at site-packages\autopep8.py

在源代码上运行全局修复程序。
这些修复只需要做一次(不像FixPEP8中的那些,它依赖于pycodestyle)。

### 🌿95 extract_code_from_function(function)
> extract_code_from_function(function), module=autopep8, line:3691 at site-packages\autopep8.py

由函数处理的返回代码。

### 🌿96 _get_package_version()
> _get_package_version(), module=autopep8, line:3708 at site-packages\autopep8.py
### 🌿97 create_parser()
> create_parser(), module=autopep8, line:3713 at site-packages\autopep8.py

返回命令行解析器。

### 🌿98 _expand_codes(codes, ignore_codes)
> _expand_codes(codes, ignore_codes), module=autopep8, line:3786 at site-packages\autopep8.py

扩展到单独的E/W代码

### 🌿99 parse_args(arguments, apply_config=False)
> parse_args(arguments, apply_config=False), module=autopep8, line:3824 at site-packages\autopep8.py

解析命令行选项。

### 🌿100 _get_normalize_options(args, config, section, option_list)
> _get_normalize_options(args, config, section, option_list), module=autopep8, line:3958 at site-packages\autopep8.py
### 🌿101 read_config(args, parser)
> read_config(args, parser), module=autopep8, line:3978 at site-packages\autopep8.py

读取用户配置和本地配置。

### 🌿102 read_pyproject_toml(args, parser)
> read_pyproject_toml(args, parser), module=autopep8, line:4029 at site-packages\autopep8.py

读 pyproject.toml 和加载配置。

### 🌿103 _split_comma_separated(string)
> _split_comma_separated(string), module=autopep8, line:4086 at site-packages\autopep8.py

返回一组字符串。

### 🌿104 decode_filename(filename)
> decode_filename(filename), module=autopep8, line:4091 at site-packages\autopep8.py

返回Unicode文件名。

### 🌿105 supported_fixes()
> supported_fixes(), module=autopep8, line:4099 at site-packages\autopep8.py

产生autopep8修复的pep8错误代码。我们生成的每一项都是一个代码元组,后面跟着它的描述。

### 🌿106 docstring_summary(docstring)
> docstring_summary(docstring), module=autopep8, line:4127 at site-packages\autopep8.py

返回文档字符串的摘要。

### 🌿107 line_shortening_rank(candidate, indent_word, max_line_length, experimental=False)
> line_shortening_rank(candidate, indent_word, max_line_length, experimental=False), module=autopep8, line:4132 at site-packages\autopep8.py

返回候选人的级别。这是用来排序候选人的。
"```

🌿108 standard_deviation(numbers)

standard_deviation(numbers), module=autopep8, line:4280 at site-packages\autopep8.py

返回标准差。

🌿109 has_arithmetic_operator(line)

has_arithmetic_operator(line), module=autopep8, line:4290 at site-packages\autopep8.py

如果行包含任何算术运算符则返回True。

🌿110 count_unbalanced_brackets(line)

count_unbalanced_brackets(line), module=autopep8, line:4299 at site-packages\autopep8.py

返回不匹配的开/闭括号的个数。

🌿111 split_at_offsets(line, offsets)

split_at_offsets(line, offsets), module=autopep8, line:4308 at site-packages\autopep8.py

在偏移量处分割行。返回字符串列表。
"```
### 🌿112 match_file(filename, exclude)
> match_file(filename, exclude), module=autopep8, line:4347 at site-packages\autopep8.py

如果文件可以修改/递归,返回True。

### 🌿113 find_files(filenames, recursive, exclude)
> find_files(filenames, recursive, exclude), module=autopep8, line:4366 at site-packages\autopep8.py

Yield文件名。

### 🌿114 _fix_file(parameters)
> _fix_file(parameters), module=autopep8, line:4388 at site-packages\autopep8.py

用于可选地并行运行fix_file()的辅助函数。

### 🌿115 fix_multiple_files(filenames, options, output=None)
> fix_multiple_files(filenames, options, output=None), module=autopep8, line:4399 at site-packages\autopep8.py

修复文件列表。可选地递归修复文件。
"```

🌿116 is_python_file(filename)

is_python_file(filename), module=autopep8, line:4438 at site-packages\autopep8.py

如果filename是Python文件返回True。

🌿117 is_probably_part_of_multiline(line)

is_probably_part_of_multiline(line), module=autopep8, line:4460 at site-packages\autopep8.py

如果line可能是多行字符串的一部分,则返回True。当涉及到多行字符串时,pep8将错误报告为位于多行字符串的开头,这对我们来说不起作用。

🌿118 wrap_output(output, encoding)

wrap_output(output, encoding), module=autopep8, line:4474 at site-packages\autopep8.py

返回带有指定编码的输出。

🌿119 get_encoding()

get_encoding(), module=autopep8, line:4481 at site-packages\autopep8.py

返回首选编码。

🌿120 main(argv=None, apply_config=True)

main(argv=None, apply_config=True), module=autopep8, line:4486 at site-packages\autopep8.py

命令行条目。

🔵类

🌿121 configparser.ConfigParser

ConfigParser, configparser.ConfigParser, module=configparser, line:0 at

ConfigParser实现插值。
method
1 add_section(self, section)

kind=method class=ConfigParser objtype=function line:1200 at …\configparser.py

在配置中创建一个新部分。RawConfigParser.add_section 延伸,通过验证节名是否为字符串来添加节。
"```
> #### 2	set(self, section, option, value=None)
> kind=method	class=ConfigParser	objtype=function	line:1194 at ...\configparser.py

设置一个选项。RawConfigParser.set 延伸,通过验证值的类型和插值语法来设置。
"```

🌿122 configparser.Error

Error, configparser.Error, module=configparser, line:0 at

ConfigParser异常的基类。

🌿123 autopep8.FixPEP8

FixPEP8, autopep8.FixPEP8, module=autopep8, line:418 at site-packages\autopep8.py

修复无效代码。
    Fixer方法的前缀是"fix_"。_fix_source()方法会自动查找这些错误。
    fixer方法可以接受一个或两个参数(除了self)。第一个参数是"result",它是pycodestyle中的错误信息。
    第二个参数“logical”仅用于逻辑行修复。
    fixer方法可以返回修改行列表或None。空列表意味着没有做任何更改。
    没有表示只修改了pycodestyle错误中报告的行。
    注意,返回的修改后的行号以1为索引。
    这通常与pycodestyle错误信息中报告的行号相对应。
    [固定方法列表]
        - e111,e114,e115,e116
        - e121,e122,e123,e124,e125,e126,e127,e128,e129
        - e201,e202,e203
        - e211
        - e221,e222,e223,e224,e225
        - e231
        - e251,e252
        - e261,e262
        - e271,e272,e273,e274,e275
        - e301,e302,e303,e304,e305,e306
        - e401,e402
        - e502
        - e701,e702,e703,e704
        - e711,e712,e713,e714
        - e722
        - e731
        - w291
        - w503,504
method
1 fix(self)

kind=method class=FixPEP8 objtype=function line:589 at …\lib\site-packages\autopep8.py

返回修复了PEP 8违规的源代码版本。
2 fix_e112(self, result)

kind=method class=FixPEP8 objtype=function line:637 at …\lib\site-packages\autopep8.py

修复缩进不足的注释。
3 fix_e113(self, result)

kind=method class=FixPEP8 objtype=function line:648 at …\lib\site-packages\autopep8.py

修复意外缩进。
4 fix_e116(self, result)

kind=method class=FixPEP8 objtype=function line:656 at …\lib\site-packages\autopep8.py

修复过度缩进的注释。
5 fix_e117(self, result)

kind=method class=FixPEP8 objtype=function line:670 at …\lib\site-packages\autopep8.py

修复over-indented。
6 fix_e125(self, result)

kind=method class=FixPEP8 objtype=function line:683 at …\lib\site-packages\autopep8.py

修复与下一个逻辑行不区分的缩进。
7 fix_e131(self, result)

kind=method class=FixPEP8 objtype=function line:701 at …\lib\site-packages\autopep8.py

修复与下一个逻辑行不区分的缩进。
8 fix_e201(self, result)

kind=method class=FixPEP8 objtype=function line:721 at …\lib\site-packages\autopep8.py

删除多余的空白。
9 fix_e224(self, result)

kind=method class=FixPEP8 objtype=function line:733 at …\lib\site-packages\autopep8.py

删除操作符周围多余的空白。
10 fix_e225(self, result)

kind=method class=FixPEP8 objtype=function line:740 at …\lib\site-packages\autopep8.py

修复了操作符周围缺失的空白。
11 fix_e231(self, result)

kind=method class=FixPEP8 objtype=function line:771 at …\lib\site-packages\autopep8.py

添加缺失的空白。
12 fix_e251(self, result)

kind=method class=FixPEP8 objtype=function line:779 at …\lib\site-packages\autopep8.py

删除参数'='符号周围的空白。
13 fix_e262(self, result)

kind=method class=FixPEP8 objtype=function line:806 at …\lib\site-packages\autopep8.py

修复内联注释散列后的空格。
14 fix_e265(self, result)

kind=method class=FixPEP8 objtype=function line:818 at …\lib\site-packages\autopep8.py

修复块注释散列后的空格。
15 fix_e266(self, result)

kind=method class=FixPEP8 objtype=function line:836 at …\lib\site-packages\autopep8.py

修复了过多的块注释哈希。
16 fix_e271(self, result)

kind=method class=FixPEP8 objtype=function line:849 at …\lib\site-packages\autopep8.py

修复关键字周围多余的空白。
17 fix_e301(self, result)

kind=method class=FixPEP8 objtype=function line:864 at …\lib\site-packages\autopep8.py

添加缺失的空行。
18 fix_e302(self, result)

kind=method class=FixPEP8 objtype=function line:869 at …\lib\site-packages\autopep8.py

添加缺失的2个空白行。
19 fix_e303(self, result)

kind=method class=FixPEP8 objtype=function line:880 at …\lib\site-packages\autopep8.py

删除多余的空行。
20 fix_e304(self, result)

kind=method class=FixPEP8 objtype=function line:899 at …\lib\site-packages\autopep8.py

删除函数装饰器后面的空白行。
21 fix_e305(self, result)

kind=method class=FixPEP8 objtype=function line:905 at …\lib\site-packages\autopep8.py

在函数或类结束后添加缺失的2个空行。
22 fix_e401(self, result)

kind=method class=FixPEP8 objtype=function line:938 at …\lib\site-packages\autopep8.py

将导入放到单独的行上。
23 fix_e402(self, result)

kind=method class=FixPEP8 objtype=function line:953 at …\lib\site-packages\autopep8.py

24 fix_e502(self, result)

kind=method class=FixPEP8 objtype=function line:1059 at …\lib\site-packages\autopep8.py

删除多余的换行符。
25 fix_e701(self, result)

kind=method class=FixPEP8 objtype=function line:1065 at …\lib\site-packages\autopep8.py

将冒号分隔的复合语句放在单独的行上。
26 fix_e702(self, result, logical)

kind=method class=FixPEP8 objtype=function line:1077 at …\lib\site-packages\autopep8.py

将分号分隔的复合语句放在单独的行上。
27 fix_e704(self, result)

kind=method class=FixPEP8 objtype=function line:1125 at …\lib\site-packages\autopep8.py

修复一行定义中的多条语句
28 fix_e711(self, result)

kind=method class=FixPEP8 objtype=function line:1136 at …\lib\site-packages\autopep8.py

修复与None的比较。
29 fix_e712(self, result)

kind=method class=FixPEP8 objtype=function line:1158 at …\lib\site-packages\autopep8.py

修复与布尔值的比较(微不足道的情况)。
30 fix_e713(self, result)

kind=method class=FixPEP8 objtype=function line:1196 at …\lib\site-packages\autopep8.py

修复非成员性检查的问题。
31 fix_e714(self, result)

kind=method class=FixPEP8 objtype=function line:1228 at …\lib\site-packages\autopep8.py

修复对象标识应该是'is not'的情况。
32 fix_e722(self, result)

kind=method class=FixPEP8 objtype=function line:1259 at …\lib\site-packages\autopep8.py

修复裸除
33 fix_e731(self, result)

kind=method class=FixPEP8 objtype=function line:1269 at …\lib\site-packages\autopep8.py

修复了不分配lambda表达式检查的问题。
34 fix_long_line(self, target, previous_line,

kind=method class=FixPEP8 objtype=function line:1028 at …\lib\site-packages\autopep8.py

35 fix_long_line_logically(self, result, logical)

kind=method class=FixPEP8 objtype=function line:970 at …\lib\site-packages\autopep8.py

尽量使行适合 --max-line-length 字符。
36 fix_long_line_physically(self, result)

kind=method class=FixPEP8 objtype=function line:1005 at …\lib\site-packages\autopep8.py

尽量使行适合 --max-line-length 字符。
37 fix_w291(self, result)

kind=method class=FixPEP8 objtype=function line:1280 at …\lib\site-packages\autopep8.py

删除尾随空格。
38 fix_w391(self, _)

kind=method class=FixPEP8 objtype=function line:1285 at …\lib\site-packages\autopep8.py

删除尾随的空行。
39 fix_w503(self, result)

kind=method class=FixPEP8 objtype=function line:1299 at …\lib\site-packages\autopep8.py

40 fix_w504(self, result)

kind=method class=FixPEP8 objtype=function line:1375 at …\lib\site-packages\autopep8.py

41 fix_w605(self, result)

kind=method class=FixPEP8 objtype=function line:1433 at …\lib\site-packages\autopep8.py

🌿124 autopep8.Token

Token, autopep8.Token, module=autopep8, line:-1 at site-packages\autopep8.py

Token(token_type, token_string, spos, epos, line)
property

1 epos=<property object at 0x00000174F4886BD8> kind:property type:property class:<class ‘autopep8.Token’>
2 line=<property object at 0x00000174F4886C28> kind:property type:property class:<class ‘autopep8.Token’>
3 spos=<property object at 0x00000174F4886B88> kind:property type:property class:<class ‘autopep8.Token’>
4 token_string=<property object at 0x00000174F4886B38> kind:property type:property class:<class ‘autopep8.Token’>
5 token_type=<property object at 0x00000174F4886AE8> kind:property type:property class:<class ‘autopep8.Token’>

🌿125 autopep8.ReformattedLines

ReformattedLines, autopep8.ReformattedLines, module=autopep8, line:1991 at site-packages\autopep8.py

原子的回流线。
    这条线的每一部分都表示为一个“原子”。可以在需要时移动它们以获得最佳格式。
method
1 add(self, obj, indent_amt, break_after_open_bracket)

kind=method class=ReformattedLines objtype=function line:2052 at …\lib\site-packages\autopep8.py

2 add_comment(self, item)

kind=method class=ReformattedLines objtype=function line:2059 at …\lib\site-packages\autopep8.py

3 add_indent(self, indent_amt)

kind=method class=ReformattedLines objtype=function line:2073 at …\lib\site-packages\autopep8.py

4 add_line_break(self, indent)

kind=method class=ReformattedLines objtype=function line:2076 at …\lib\site-packages\autopep8.py

5 add_line_break_at(self, index, indent_amt)

kind=method class=ReformattedLines objtype=function line:2080 at …\lib\site-packages\autopep8.py

6 add_space_if_needed(self, curr_text, equal=False)

kind=method class=ReformattedLines objtype=function line:2084 at …\lib\site-packages\autopep8.py

7 current_size(self)

kind=method class=ReformattedLines objtype=function line:2137 at …\lib\site-packages\autopep8.py

当前行的大小减去缩进。
8 emit(self)

kind=method class=ReformattedLines objtype=function line:2010 at …\lib\site-packages\autopep8.py

9 fits_on_current_line(self, item_extent)

kind=method class=ReformattedLines objtype=function line:2134 at …\lib\site-packages\autopep8.py

10 line_empty(self)

kind=method class=ReformattedLines objtype=function line:2147 at …\lib\site-packages\autopep8.py

11 previous_item(self)

kind=method class=ReformattedLines objtype=function line:2130 at …\lib\site-packages\autopep8.py

返回前一个非空白项。

🌿126 autopep8.Atom

Atom, autopep8.Atom, module=autopep8, line:2340 at site-packages\autopep8.py

可以回流的最小的牢不可破的单元。
property

1 is_colon=<property object at 0x00000174F488F368> kind:property type:property class:<class ‘autopep8.Atom’>
2 is_comma=<property object at 0x00000174F488F318> kind:property type:property class:<class ‘autopep8.Atom’>
3 is_keyword=<property object at 0x00000174F488F1D8> kind:property type:property class:<class ‘autopep8.Atom’>
4 is_name=<property object at 0x00000174F488F278> kind:property type:property class:<class ‘autopep8.Atom’>
5 is_number=<property object at 0x00000174F488F2C8> kind:property type:property class:<class ‘autopep8.Atom’>
6 is_string=<property object at 0x00000174F488F228> kind:property type:property class:<class ‘autopep8.Atom’>
7 size=<property object at 0x00000174F488F3B8> kind:property type:property class:<class ‘autopep8.Atom’>

method
8 emit(self)

kind=method class=Atom objtype=function line:2389 at …\lib\site-packages\autopep8.py

9 reflow(

kind=method class=Atom objtype=function line:2353 at …\lib\site-packages\autopep8.py

🌿127 autopep8.Container

Container, autopep8.Container, module=autopep8, line:2421 at site-packages\autopep8.py

所有容器类型的基类。
property

1 close_bracket=<property object at 0x00000174F488F728> kind:property type:property class:<class ‘autopep8.Container’>
2 is_colon=<property object at 0x00000174F488F688> kind:property type:property class:<class ‘autopep8.Container’>
3 is_comma=<property object at 0x00000174F488F638> kind:property type:property class:<class ‘autopep8.Container’>
4 is_keyword=<property object at 0x00000174F488F598> kind:property type:property class:<class ‘autopep8.Container’>
5 is_name=<property object at 0x00000174F488F5E8> kind:property type:property class:<class ‘autopep8.Container’>
6 is_string=<property object at 0x00000174F488F4F8> kind:property type:property class:<class ‘autopep8.Container’>
7 open_bracket=<property object at 0x00000174F488F6D8> kind:property type:property class:<class ‘autopep8.Container’>
8 size=<property object at 0x00000174F488F548> kind:property type:property class:<class ‘autopep8.Container’>

method
9 reflow(self, reflowed_lines, continued_indent,

kind=method class=Container objtype=function line:2458 at …\lib\site-packages\autopep8.py

🌿128 autopep8.Tuple

Tuple, autopep8.Tuple, module=autopep8, line:2575 at site-packages\autopep8.py

元组的高级表示。
property

1 close_bracket=<property object at 0x00000174F488F8B8> kind:property type:property class:<class ‘autopep8.Tuple’>
2 open_bracket=<property object at 0x00000174F488F868> kind:property type:property class:<class ‘autopep8.Tuple’>

🌿129 autopep8.List

List, autopep8.List, module=autopep8, line:2588 at site-packages\autopep8.py

列表的高级表示形式。
property

1 close_bracket=<property object at 0x00000174F488F9F8> kind:property type:property class:<class ‘autopep8.List’>
2 open_bracket=<property object at 0x00000174F488F9A8> kind:property type:property class:<class ‘autopep8.List’>

🌿130 autopep8.DictOrSet

DictOrSet, autopep8.DictOrSet, module=autopep8, line:2601 at site-packages\autopep8.py

字典或集合的高级表示形式。
property

1 close_bracket=<property object at 0x00000174F488FB38> kind:property type:property class:<class ‘autopep8.DictOrSet’>
2 open_bracket=<property object at 0x00000174F488FAE8> kind:property type:property class:<class ‘autopep8.DictOrSet’>

🌿131 autopep8.ListComprehension

ListComprehension, autopep8.ListComprehension, module=autopep8, line:2614 at site-packages\autopep8.py

列表推导式的高级表示形式。
property

1 size=<property object at 0x00000174F488FC28> kind:property type:property class:<class ‘autopep8.ListComprehension’>

🌿132 autopep8.IfExpression

IfExpression, autopep8.IfExpression, module=autopep8, line:2628 at site-packages\autopep8.py

if表达式的高级表示形式。

🌿133 autopep8.Reindenter

Reindenter, autopep8.Reindenter, module=autopep8, line:2981 at site-packages\autopep8.py

重新缩进严重缩进的代码,统一使用四个空格缩进。由Tim Peters于2000年10月3日发布到公共领域。
"```
#### method
> #### 1	getline(self)
> kind=method	class=Reindenter	objtype=function	line:3103 at ...\lib\site-packages\autopep8.py

用于标记的行getter。

> #### 2	run(self, indent_size=DEFAULT_INDENT_SIZE)
> kind=method	class=Reindenter	objtype=function	line:3021 at ...\lib\site-packages\autopep8.py

修复缩进并返回修改后的行号。行号以1为索引。
"```

🌿134 autopep8.LineEndingWrapper

LineEndingWrapper, autopep8.LineEndingWrapper, module=autopep8, line:4328 at site-packages\autopep8.py

将行尾替换为sys.stdout。似乎……无论平台如何,标准输出只期望'\n'作为行结尾。否则,我们会得到重复的行尾。
method
1 flush(self)

kind=method class=LineEndingWrapper objtype=function line:4343 at …\lib\site-packages\autopep8.py

2 write(self, s)

kind=method class=LineEndingWrapper objtype=function line:4340 at …\lib\site-packages\autopep8.py

🌿135 autopep8.CachedTokenizer

CachedTokenizer, autopep8.CachedTokenizer, module=autopep8, line:4542 at site-packages\autopep8.py

围绕 tokenize.generate_tokens() 的单元素缓存。
原始代码由Ned Batchelder编写,在coverage.py中。
method
1 generate_tokens(self, text)

kind=method class=CachedTokenizer objtype=function line:4554 at …\lib\site-packages\autopep8.py

tokenize.generate_tokens() 标准输入。

🔵私有或局部

136 _find_logical <function _find_logical at 0x00000174F488BE58>
137 _get_logical <function _get_logical at 0x00000174F488BEE8>
138 _get_indentword <function _get_indentword at 0x00000174F488C438>
139 _get_indentation <function _get_indentation at 0x00000174F488C4C8>
140 _priority_key <function _priority_key at 0x00000174F488C5E8>
141 _shorten_line <function _shorten_line at 0x00000174F488C708>
142 _is_binary_operator <function _is_binary_operator at 0x00000174F488C798>
143 _parse_container <function _parse_container at 0x00000174F488CC18>
144 _parse_tokens <function _parse_tokens at 0x00000174F4891E58>
145 _reflow_lines <function _reflow_lines at 0x00000174F4891EE8>
146 _shorten_line_at_tokens_new <function _shorten_line_at_tokens_new at 0x00000174F4891F78>
147 _shorten_line_at_tokens <function _shorten_line_at_tokens at 0x00000174F4892048>
148 _execute_pep8 <function _execute_pep8 at 0x00000174F4892288>
149 _remove_leading_and_normalize <function _remove_leading_and_normalize at 0x00000174F4892318>
150 _reindent_stats <function _reindent_stats at 0x00000174F48923A8>
151 _leading_space_count <function _leading_space_count at 0x00000174F48925E8>
152 _get_options <function _get_options at 0x00000174F4892DC8>
153 _get_parameters <function _get_parameters at 0x00000174F4893048>
154 _get_package_version <function _get_package_version at 0x00000174F48931F8>
155 _expand_codes <function _expand_codes at 0x00000174F4893318>
156 _get_normalize_options <function _get_normalize_options at 0x00000174F4893438>
157 _split_comma_separated <function _split_comma_separated at 0x00000174F48935E8>
158 _fix_file <function _fix_file at 0x00000174F4893DC8>
159 _cached_tokenizer <autopep8.CachedTokenizer object at 0x00000174F4884648>

🔵剩余

160 loader <_frozen_importlib_external.SourceFileLoader object at 0x00000174F475CF48>
161 spec ModuleSpec(name=‘autopep8’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x00000174F475CF48>, origin=‘…\lib\site-packages\autopep8.py’)
162 absolute_import _Feature((2, 5, 0, ‘alpha’, 1), (3, 0, 0, ‘alpha’, 0), 16384)
163 division _Feature((2, 2, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 8192)
164 print_function _Feature((2, 6, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 65536)
165 unicode_literals _Feature((2, 6, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 131072)
166 STARTSWITH_INDENT_STATEMENT_REGEX re.compile(‘^\s*(def|async\s+def|for|async\s+for|if|elif|else|try|except|finally|with|async\s+with|class|while)\b’)
167 PYTHON_SHEBANG_REGEX re.compile(‘^#!.\bpython[23]?\b\s$’)
168 LAMBDA_REGEX re.compile(‘([\w.]+)\s=\slambda\s*([)(=\w,\s.]):‘)
169 COMPARE_NEGATIVE_REGEX re.compile(’\b(not)\s+([^][)(}{]+?)\s+(in|is)\s’)
170 COMPARE_NEGATIVE_REGEX_THROUGH re.compile(‘\b(not\s+in|is\s+not)\s’)
171 BARE_EXCEPT_REGEX re.compile('except\s
:’)
172 STARTSWITH_DEF_REGEX re.compile(‘^(async\s+def|def)\s.*\):’)
173 DOCSTRING_START_REGEX re.compile(‘^u?r?(?P["\’]{3})‘)
174 ENABLE_REGEX re.compile(’# *(fmt|autopep8): *on’)
175 DISABLE_REGEX re.compile(‘# (fmt|autopep8): off’)
176 SHORTEN_OPERATOR_GROUPS frozenset({frozenset({‘,’}), frozenset({‘-’, ‘//’, ‘%’, ‘+’, ‘/’, '
‘}), frozenset({’%‘}), frozenset({’{‘, ‘,’, ‘[’, ‘(’}), frozenset({’{', ‘(’, ‘,’, ‘[’, ‘-’, ‘//’, ‘%’, ‘+’, ‘/’, '
’}), frozenset({‘%’, ‘[’, ‘{’, ‘(’})})
177 _cached_tokenizer <autopep8.CachedTokenizer object at 0x00000174F4884648>
178 generate_tokens <bound method CachedTokenizer.generate_tokens of <autopep8.CachedTokenizer object at 0x00000174F4884648>>

☘️【argparse】

argparse, fullname=argparse, file=argparse.py

☘️【codecs】

codecs, fullname=codecs, file=codecs.py

☘️【collections】

collections, fullname=collections, file=collections_init_.py

☘️【copy】

copy, fullname=copy, file=copy.py

☘️【difflib】

difflib, fullname=difflib, file=difflib.py

☘️【fnmatch】

fnmatch, fullname=fnmatch, file=fnmatch.py

☘️【inspect】

inspect, fullname=inspect, file=inspect.py

☘️【io】

io, fullname=io, file=io.py

☘️【itertools】

itertools, fullname=itertools

☘️【keyword】

keyword, fullname=keyword, file=keyword.py

☘️【locale】

locale, fullname=locale, file=locale.py

☘️【os】

os, fullname=os, file=os.py

☘️【re】

re, fullname=re, file=re.py

☘️【signal】

signal, fullname=signal, file=signal.py

☘️【sys】

sys, fullname=sys

☘️【textwrap】

textwrap, fullname=textwrap, file=textwrap.py

☘️【token】

token, fullname=token, file=token.py

☘️【tokenize】

tokenize, fullname=tokenize, file=tokenize.py

☘️【warnings】

warnings, fullname=warnings, file=warnings.py

☘️【ast】

ast, fullname=ast, file=ast.py

☘️【pycodestyle】

pycodestyle, fullname=pycodestyle, file=pycodestyle.py

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AhcaoZhu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值