{"id":7,"date":"2009-10-23T11:19:00","date_gmt":"2009-10-23T09:19:00","guid":{"rendered":"http:\/\/blog.gocept.com\/?p=7"},"modified":"2012-12-03T15:11:20","modified_gmt":"2012-12-03T14:11:20","slug":"automatic-pep-8-checking-in-vim","status":"publish","type":"post","link":"https:\/\/blog.gocept.com\/2009\/10\/23\/automatic-pep-8-checking-in-vim\/","title":{"rendered":"Automatic Python syntax and PEP 8 checking in VIM"},"content":{"rendered":"

I fiddled a bit for making my VIM tell me when obvious (statically detectable) mistakes sit in my code when saving. This speeds up the testing process a bit when e.g. syntax errors exist and helps me adhere to PEP 8.<\/p>\n

<\/p>\n

I use vim’s ftplugin which has the following settings in ~\/.vim\/ftplugin\/python.vim:<\/p>\n

setlocal makeprg=pep8\\ --repeat\\ %\r\nautocmd BufWritePost  call Checkpep8()<\/pre>\n

In my ~\/.vimrc the Checkpep8 function is defined as follows:<\/p>\n

function Checkpep8 ()\r\n silent make\r\n redraw!\r\n if len(getqflist())\r\n    cl\r\n endif\r\nendfunction Checkpep8<\/pre>\n

The effort of the custom function is in avoiding to get the <PRESS ENTER> message from the shell command if no errors exist. The only minor annoyance with my solution is that the message “file written…” disappears more quickly than normally.<\/p>\n","protected":false},"excerpt":{"rendered":"

I fiddled a bit for making my VIM tell me when obvious (statically detectable) mistakes sit in my code when saving. This speeds up the testing process a bit when e.g. syntax errors exist and helps me adhere to PEP 8.<\/p>\n","protected":false},"author":12391367,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[10221],"tags":[18060],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pFP3y-7","jetpack-related-posts":[{"id":423,"url":"https:\/\/blog.gocept.com\/2013\/02\/18\/developer-admin-bbq-iv\/","url_meta":{"origin":7,"position":0},"title":"developer & admin BBQ IV","author":"Daniel Havlik","date":"February 18, 2013","format":false,"excerpt":"Zum vierten Mal wird am 30. April 2013 um 14:00 Uhr das \u201edeveloper & admin BBQ\u201c stattfinden. Die Veranstaltung bietet Software-Entwicklern und Administratoren ein Forum um Ideen, Probleme und deren L\u00f6sungen auszutauschen. In einem an \u201eOpen Space\u201c\u00a0angelehnten Format hat jeder Teilnehmer die M\u00f6glichkeit eigene Themen einzubringen, die dann in kleineren\u2026","rel":"","context":"In "de"","block_context":{"text":"de","link":"https:\/\/blog.gocept.com\/category\/de\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3219,"url":"https:\/\/blog.gocept.com\/2018\/04\/17\/allow-hosts-in-buildout-considered-harmful\/","url_meta":{"origin":7,"position":1},"title":"“allow-hosts” in buildout considered harmful","author":"Michael Howitz","date":"April 17, 2018","format":false,"excerpt":"Today we had the following error message when re-installing a project from scratch: While: Installing. Getting section application. Initializing section application. Installing recipe zc.zope3recipes. Getting distribution for 'zc.zope3recipes==0.13.0'. Error: Couldn't find a distribution for 'zc.zope3recipes==0.13.0'. Yes this is a really old recipe but it still exists on PyPI. We are\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2890,"url":"https:\/\/blog.gocept.com\/2017\/10\/24\/zope4-errorhandling\/","url_meta":{"origin":7,"position":2},"title":"Catching and rendering exceptions","author":"Michael Howitz","date":"October 24, 2017","format":false,"excerpt":"Error handling in Zope 4","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":349,"url":"https:\/\/blog.gocept.com\/2012\/12\/17\/yafowil-in-a-pyramid-project\/","url_meta":{"origin":7,"position":3},"title":"yafowil in a Pyramid project","author":"Michael Howitz","date":"December 17, 2012","format":false,"excerpt":"In a new Pyramid\u00a0project we used deform\u00a0to render forms. We did not really like it. (The reasons might be detailed in another post.) To see if other form libraries do better I\u00a0gave yafowil\u00a0a try at our\u00a0gocept Developer Punsch\u00a03: yafowil comes with written documentation. To get a form in our Pyramid\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2789,"url":"https:\/\/blog.gocept.com\/2017\/10\/25\/testing-zope-4beta2\/","url_meta":{"origin":7,"position":4},"title":"Migrating from Zope 2.13 to 4.0b2","author":"Michael Howitz","date":"October 25, 2017","format":false,"excerpt":"Beta-Testing Zope 4 together with PerFact Innovation","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1873,"url":"https:\/\/blog.gocept.com\/2016\/10\/26\/towards-restrictedpython-3\/","url_meta":{"origin":7,"position":5},"title":"Towards RestrictedPython 3","author":"Michael Howitz","date":"October 26, 2016","format":false,"excerpt":"The biggest blocker to port Zope to Python 3 is\u00a0RestrictedPython. What is RestrictedPython? It is a library used by Zope to restrict Python code at instruction level to a bare minimum of trusted functionality. It\u00a0parses and filters the code for not\u00a0allowed constructs (such as\u00a0open()) and adds wrappers around\u00a0each access on\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.gocept.com\/wp-content\/uploads\/2016\/10\/zope-is-not-dead.jpg?fit=1200%2C658&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.gocept.com\/wp-content\/uploads\/2016\/10\/zope-is-not-dead.jpg?fit=1200%2C658&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.gocept.com\/wp-content\/uploads\/2016\/10\/zope-is-not-dead.jpg?fit=1200%2C658&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/blog.gocept.com\/wp-content\/uploads\/2016\/10\/zope-is-not-dead.jpg?fit=1200%2C658&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/blog.gocept.com\/wp-content\/uploads\/2016\/10\/zope-is-not-dead.jpg?fit=1200%2C658&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/posts\/7"}],"collection":[{"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/users\/12391367"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":5,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":334,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/posts\/7\/revisions\/334"}],"wp:attachment":[{"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}