AI-performance / embedded-ai.bench

benchmark for embededded-ai deep learning inference engines, such as NCNN / TNN / MNN / TensorFlow Lite etc.
https://www.ai-performance.com
Other
202 stars 29 forks source link

[CI] 增加pre-commit对python代码做语法和格式检查 #4

Closed ysh329 closed 4 years ago

ysh329 commented 4 years ago

用 pre-commit hook 解决 Python 项目编码规范 - 掘金 https://juejin.im/post/5cdb8adc518825697d771349

CI也要加入

flake8

Flake 8会报出一个信息:

line too long (791 > 79 characters) E501 怎么解决呢?

于是我查了一下,引入一个长字符串的情况下,如果想让某一行被Flake 8忽略,而不报警行太长,可以用 # noqa 标记来解决,把它放在行尾即可。

ysh329 commented 4 years ago

flake8

http://www.panxiaonan.cc/emlog/post-28.html

code sample message
E1 Indentation缩进
E101 indentation contains mixed spaces and tabs缩进包含混合空格和制表符
E111 indentation is not a multiple of four缩进不是四的倍数
E112 expected an indented block需要缩进块
E113 unexpected indentation意外缩进
E114 indentation is not a multiple of four (comment)缩进不是四的倍数(注释)
E115 expected an indented block (comment)需要缩进块(注释)
E116 unexpected indentation (comment)意外缩进(注释)
E117 over-indented过度缩进
E121 (*^) continuation line under-indented for hanging indent缩进下的续行,用于悬挂缩进
E122 (^) continuation line missing indentation or outdented续行缺少缩进或缩进
E123 (*) closing bracket does not match indentation of opening bracket’s line右括号与左括号行的缩进不匹配
E124 (^) closing bracket does not match visual indentation右括号与视觉缩进不匹配
E125 (^) continuation line with same indent as next logical line与下一逻辑行具有相同缩进的续行
E126 (*^) continuation line over-indented for hanging indent用于挂起缩进的缩进上的续行
E127 (^) continuation line over-indented for visual indent视觉缩进的缩进上的续行
E128 (^) continuation line under-indented for visual indent缩进下的连续行,用于视觉缩进
E129 (^) visually indented line with same indent as next logical line视觉缩进行,与下一逻辑行缩进相同
E131 (^) continuation line unaligned for hanging indent未对齐的续行用于挂起缩进
E133 (*) closing bracket is missing indentation右括号缺少缩进
   
E2 Whitespace空白
E201 whitespace after ‘(‘   “(”后的空白
E202 whitespace before ‘)’“)”之前的空白
E203 whitespace before ‘:’  “:”前的空白
   
E211 whitespace before ‘(‘ “(”前的空白
   
E221 multiple spaces before operator E221运算符前的多个空格
E222 multiple spaces after operatorE222运算符后的多个空格
E223 tab before operatorE223操作员前的标签
E224 tab after operatorE224操作员后标签
E225 missing whitespace around operatorE225运算符周围缺少空格
E226 (*) missing whitespace around arithmetic operatorE226(*)算术运算符周围缺少空格
E227 missing whitespace around bitwise or shift operatorE227位或移位运算符周围缺少空格
E228 missing whitespace around modulo operator E228模运算符周围缺少空格
   
E231 missing whitespace after ‘,’, ‘;’, or ‘:’ E231“,”,“;”或“:”后缺少空格
   
E241 (*) multiple spaces after ‘,’ E241(*)','后有多个空格
E242 (*) tab after ‘,’  E242(*)','后的制表符
   
E251 unexpected spaces around keyword / parameter equals E251关键字/参数等于的周围有意外空格
   
E261 at least two spaces before inline comment  E261内联注释前至少有两个空格
E262 inline comment should start with ‘# ‘  E262内联注释应以“#”开头
E265 block comment should start with ‘# ‘  E265块注释应以“35;”开头
E266 too many leading ‘#’ for block comment E266块注释的前导“35;”太多
   
E271 multiple spaces after keyword  E271关键字后有多个空格
E272 multiple spaces before keyword  E272关键字前有多个空格
E273 tab after keyword  E273关键字后的制表符
E274 tab before keyword  E274关键字前的制表符
E275 missing whitespace after keyword E275关键字后缺少空格
   
E3 Blank line  E3空行
E301 expected 1 blank line, found 0E301应为1空行,找到0
E302 expected 2 blank lines, found 0E302需要2个空行,找到0
E303 too many blank lines (3)E303空行太多(3)
E304 blank lines found after function decoratorE304函数decorator后发现空行
E305 expected 2 blank lines after end of function or classE305函数或类结束后需要2个空行
E306 expected 1 blank line before a nested definitionE306在嵌套定义之前需要1个空行
   
E4 ImportE4导入
E401 multiple imports on one lineE401一条线上的多个导入
E402 module level import not at top of fileE402模块级导入不在文件顶部
   
E5 Line lengthE5线长度
E501 (^) line too long (82 > 79 characters)E501(^)行太长(82>79个字符)
E502 the backslash is redundant between bracketsE502括号之间的反斜杠是多余的
   
E7 StatementE7报表
E701 multiple statements on one line (colon)E701一行多个语句(冒号)
E702 multiple statements on one line (semicolon)E702一行多个语句(分号)
E703 statement ends with a semicolonE703语句以分号结尾
E704 (*) multiple statements on one line (def)E704(*)一行有多个语句(def)
E711 (^) comparison to None should be ‘if cond is None:’E711(^)与None的比较应为'if cond is None:'
E712 (^) comparison to True should be ‘if cond is True:’ or ‘if cond:’E712(^)与True的比较应为'if cond is True:'或'if cond:'
E713 test for membership should be ‘not in’E713成员资格测试应为“不在”
E714 test for object identity should be ‘is not’E714对象标识的测试应为“不是”
E721 (^) do not compare types, use ‘isinstance()’E721(^)不比较类型,请使用'isinstance()'
E722 do not use bare except, specify exception insteadE722不使用bare except,而是指定exception
E731 do not assign a lambda expression, use a defE731不分配lambda表达式,使用def
E741 do not use variables named ‘l’, ‘O’, or ‘I’E741不使用名为“l”、“O”或“I”的变量
E742 do not define classes named ‘l’, ‘O’, or ‘I’E742不定义名为“l”、“O”或“I”的类
E743 do not define functions named ‘l’, ‘O’, or ‘I’E743不定义名为“l”、“O”或“I”的函数
   
E9 RuntimeE9运行时
E901 SyntaxError or IndentationErrorE901语法错误或缩进错误
E902 IOErrorE902 IO错误
   
W1 Indentation warningW1缩进警告
W191 indentation contains tabsW191缩进包含制表符
   
W2 Whitespace warningW2空白警告
W291 trailing whitespaceW291尾随空白
W292 no newline at end of fileW292文件末尾没有换行符
W293 blank line contains whitespaceW293空行包含空格
   
W3 Blank line warningW3空行警告
W391 blank line at end of fileW391文件末尾的空行
   
W5 Line break warningW5断线警告
W503 (*) line break before binary operatorW503(*)二进制运算符前的换行符
W504 (*) line break after binary operatorW504(*)二进制运算符后的换行符
W505 (*^) doc line too long (82 > 79 characters)W505(*^)文档行太长(82>79个字符)
   
W6 Deprecation warning  折旧警告
W601 .has_key() is deprecated, use ‘in’   .has_key()已弃用,请使用“in”
W602 deprecated form of raising exception   不推荐的引发异常的形式
W603 ‘<>’ is deprecated, use ‘!=’ “<>”已弃用,请使用“!=’
W604 backticks are deprecated, use ‘repr()’反勾号已弃用,请使用'repr()'
W605 invalid escape sequence ‘x’无效的转义序列“x”
W606 ‘async’ and ‘await’ are reserved keywords starting with Python 3.7 'async'和'await'是从Python 3.7开始的保留关键字
ysh329 commented 4 years ago

目前已经支持: