{"id":269,"date":"2019-05-21T15:36:13","date_gmt":"2019-05-21T06:36:13","guid":{"rendered":"https:\/\/blog.hgrs.me\/?p=269"},"modified":"2019-05-26T17:19:00","modified_gmt":"2019-05-26T08:19:00","slug":"flake8%e3%81%a7%e6%b3%a8%e6%84%8f%e3%82%92%e7%84%a1%e8%a6%96%e3%81%99%e3%82%8b%e8%89%b2%e3%80%85%e3%81%aa%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.hgrs.me\/archives\/269.html","title":{"rendered":"Flake8\u3067\u6ce8\u610f\u3092\u7121\u8996\u3059\u308b\u8272\u3005\u306a\u65b9\u6cd5"},"content":{"rendered":"
\u7686\u3055\u3093\u306f\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u969b\u306bLinter\u3068\u304b\u3092\u4f7f\u7528\u3057\u3066\u307e\u3059\u304b\uff1f<\/p>\n
\u50d5\u304c\u4e00\u756a\u3088\u304f\u4f7f\u3046\u8a00\u8a9e\u306fPython\u306a\u3093\u3067\u3059\u304cFlake8\u3092\u4f7f\u3063\u3066\u69cb\u6587\u30c1\u30a7\u30c3\u30af\uff08Lint\uff09\u3057\u3066\u307e\u3059\u3002Flake8\u306f\u69cb\u6587\u30df\u30b9\u306e\u4ed6\u306b\u3001\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u3092\u5b88\u308b\u3088\u3046\u306b\u6ce8\u610f\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3059\u304c\u3001\u6642\u3068\u5834\u5408\u306b\u3088\u3063\u3066\u306f\u3053\u306e\u6ce8\u610f\u304c\u5384\u4ecb\u306a\u6642\u304c\u3042\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u7121\u8996\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n
\u307e\u305a\u3001Flake8\u306e\u30a8\u30e9\u30fc\u7121\u8996\u306b\u95a2\u3057\u3066\u306f\u3001\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u8a18\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u3053\u3061\u3089\u3092\u53c2\u8003\u306b\u8a18\u8f09\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n \u307e\u305f\u5404\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\u4e00\u89a7\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n \u305d\u3082\u305d\u3082Flake8\u306fpip\u7b49\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305fFlake8\u3092\u4f7f\u7528\u3057\u3066\u69cb\u6587\u30c1\u30a7\u30c3\u30af\u3059\u308b\u969b\u306e\u7121\u8996\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n \u66f8\u304d\u65b9\u306f\u4ee5\u4e0b\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u66f8\u3051\u307e\u3059\u3002<\/p>\n \u3053\u3053\u3067\u306e \u4f8b\u3048\u3070 \u3053\u3061\u3089\u306e\u4f7f\u3044\u65b9\u304c\u30e1\u30a4\u30f3\u3068\u306a\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n \u3053\u3053\u3067\u306f\u884c\u5358\u4f4d\u3067\u306e\u7121\u8996\u3068\u30d5\u30a1\u30a4\u30eb\u5168\u4f53\u3067\u306e\u7121\u8996\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n \u7121\u8996\u3057\u305f\u3044\u884c\u306e\u6700\u5f8c\u306b\u30b3\u30e1\u30f3\u30c8\u3068\u3057\u3066 \u3053\u3061\u3089\u306e \u307e\u305f\u3001\u7279\u5b9a\u306e\u30a8\u30e9\u30fc\u3092\u6307\u5b9a\u305b\u305a\u3001\u5168\u3066\u306e\u30a8\u30e9\u30fc\u3092\u7121\u8996\u3057\u305f\u3044\u5834\u5408\u306b\u306f \u3053\u3061\u3089\u306e\u65b9\u6cd5\u306f\u3059\u3054\u304f\u5358\u7d14\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u306b \u3057\u304b\u3057\u3001Flake8\u3067\u306f\u3053\u306e\u65b9\u6cd5\u3088\u308a\u3082\u3001\u7121\u8996\u3057\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u3092 \u69d8\u3005\u306a\u65b9\u6cd5\u306b\u3088\u308b\u69cb\u6587\u30c1\u30a7\u30c3\u30af\u7121\u8996\u306e\u65b9\u6cd5\u3092\u8abf\u3079\u307e\u3057\u305f\u304c\u3001\u4e00\u756a\u4f7f\u3044\u305d\u3046\u306a\u306e\u306f\u884c\u5358\u4f4d\u3067\u306e\u7121\u8996\u3067\u3059\u304b\u306d\u3002<\/p>\n URL\u3068\u304b\u3067 \u306f\u3058\u3081\u306b \u7686\u3055\u3093\u306f\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u969b\u306bLinter\u3068\u304b\u3092\u4f7f\u7528\u3057\u3066\u307e\u3059\u304b\uff1f \u50d5\u304c\u4e00\u756a\u3088\u304f\u4f7f\u3046\u8a00\u8a9e\u306fPy…<\/p>\n","protected":false},"author":1,"featured_media":271,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14],"_links":{"self":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts\/269"}],"collection":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/comments?post=269"}],"version-history":[{"count":0,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts\/269\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/media\/271"}],"wp:attachment":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/media?parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/categories?post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/tags?post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\n
\u7279\u5b9a\u30d5\u30a1\u30a4\u30eb\u3067\u306e\u7121\u8996<\/h3>\n
$ flake8 --ignore=errors file file ...<\/code><\/pre>\n
errors<\/code>\u306fFlake8\u306e\u30a8\u30e9\u30fc\u756a\u53f7\u3067\u3059\u3002\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u8907\u6570\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002\u7d9a\u304f
file<\/code>\u306f\u69cb\u6587\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3067\u3053\u3061\u3089\u3082\u8907\u6570\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3082\u53ef\u3067\u3059\u3002<\/p>\n
dir<\/code>\u306b\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6587\u30c1\u30a7\u30c3\u30af\u3067E501\u3068E502\u3092\u7121\u8996\u3059\u308b\u5834\u5408\u306b\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u304c\u6709\u52b9\u3067\u3059\u3002<\/p>\n
$ flake8 --ignore=E501,E502 dir\/<\/code><\/pre>\n
\u30a8\u30c7\u30a3\u30bf\u4e0a\u3067\u306e\u7121\u8996<\/h3>\n
\u884c\u5358\u4f4d\u3067\u306e\u7121\u8996<\/h4>\n
# noqa: errors<\/code>\u3068\u3044\u3046\u5f62\u5f0f\u3067\u7121\u8996\u3059\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n
errors<\/code>\u3082\u4e0a\u8a18\u3068\u540c\u69d8\u306b\u30ab\u30f3\u30de\u533a\u5207\u308a\u306e\u30ea\u30b9\u30c8\u3068\u306a\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n
example = lambda: 'example' # noqa: E731<\/code><\/pre>\n
# noqa<\/code>\u3060\u3051\u3092\u8a18\u5165\u3059\u308b\u3053\u3068\u3067\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n
\u30d5\u30a1\u30a4\u30eb\u5168\u4f53\u3067\u306e\u7121\u8996<\/h4>\n
# flake8: noqa<\/code>\u3068\u8ffd\u8a18\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n
flake8 --exclude<\/code>\u306b\u3088\u308a\u3001\u660e\u793a\u7684\u306b\u9664\u5916\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3092\u63a8\u5968\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n
\u304a\u308f\u308a\u306b<\/h2>\n
E501<\/code>\u3068\u304b\u4f7f\u3044\u305f\u304f\u306a\u308b\u3058\u3083\u306a\u3044\u3067\u3059\u304b\u3002\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"