From razzi at abuissa.net Sun Jul 23 15:13:11 2017 From: razzi at abuissa.net (Razzi Abuissa) Date: Sun, 23 Jul 2017 19:13:11 +0000 Subject: [code-quality] Lint check for missing commas in list literal? Message-ID: <0101015d70de1f3a-c925e021-b5c5-4691-94d0-f40af05f0712-000000@us-west-2.amazonses.com> Hi PyCQA, I've done a little searching but have not found a lint check for the following: [ 'a', 'b' 'c' ] evaluates to ['a', 'bc'] due to implicit string concatenation, but usually it's intended to be ['a', 'b', 'c']. If it is meant to be ['a', 'bc'] it's bad style. Guido recommends popular lint tools add a rule for this here: https://groups.google.com/forum/#!msg/python-ideas/jP1YtlyJqxs/FacZu-WK_9AJ If this check does not exist, I would be willing to create a flake8 plugin and add it to PyCQA. Regards, Razzi -------------- next part -------------- An HTML attachment was scrubbed... URL: From graffatcolmingov at gmail.com Mon Jul 24 07:07:26 2017 From: graffatcolmingov at gmail.com (Ian Stapleton Cordasco) Date: Mon, 24 Jul 2017 06:07:26 -0500 Subject: [code-quality] Lint check for missing commas in list literal? In-Reply-To: <0101015d70de1f3a-c925e021-b5c5-4691-94d0-f40af05f0712-000000@us-west-2.amazonses.com> References: <0101015d70de1f3a-c925e021-b5c5-4691-94d0-f40af05f0712-000000@us-west-2.amazonses.com> Message-ID: On Sun, Jul 23, 2017 at 2:13 PM, Razzi Abuissa wrote: > Hi PyCQA, > > I've done a little searching but have not found a lint check for the > following: > > [ > 'a', > 'b' > 'c' > ] > > evaluates to ['a', 'bc'] due to implicit string concatenation, but usually > it's intended to be ['a', 'b', 'c']. If it is meant to be ['a', 'bc'] it's > bad style. > > Guido recommends popular lint tools add a rule for this here: > https://groups.google.com/forum/#!msg/python-ideas/jP1YtlyJqxs/FacZu-WK_9AJ > > If this check does not exist, I would be willing to create a flake8 plugin > and add it to PyCQA. > > Regards, > > Razzi Hi Razzi, This has been discussed here https://github.com/PyCQA/pycodestyle/issues/308 and there are a few plugins for Flake8 which do this: - https://pypi.org/project/flake8-commas/ - https://pypi.org/project/flake8-trailing-commas/ - https://pypi.org/project/flake8_strict/ You can find Flake8 plugins using this search on PyPI: https://pypi.org/search/?c=Framework+::+Flake8 Cheers, Ian From mauve at mauveweb.co.uk Mon Jul 24 07:06:24 2017 From: mauve at mauveweb.co.uk (Daniel Pope) Date: Mon, 24 Jul 2017 11:06:24 +0000 Subject: [code-quality] Lint check for missing commas in list literal? In-Reply-To: <0101015d70de1f3a-c925e021-b5c5-4691-94d0-f40af05f0712-000000@us-west-2.amazonses.com> References: <0101015d70de1f3a-c925e021-b5c5-4691-94d0-f40af05f0712-000000@us-west-2.amazonses.com> Message-ID: I have written that check previously - specifically for a missing comma in a list-like context. I will see if I can find the code for it. On Mon, 24 Jul 2017, 12:01 Razzi Abuissa, wrote: > Hi PyCQA, > > I've done a little searching but have not found a lint check for the > following: > > [ > 'a', > 'b' > 'c' > ] > > evaluates to ['a', 'bc'] due to implicit string concatenation, but usually > it's intended to be ['a', 'b', 'c']. If it is meant to be ['a', 'bc'] it's > bad style. > > Guido recommends popular lint tools add a rule for this here: > https://groups.google.com/forum/#!msg/python-ideas/jP1YtlyJqxs/FacZu-WK_9AJ > > If this check does not exist, I would be willing to create a flake8 plugin > and add it to PyCQA. > > Regards, > > Razzi > _______________________________________________ > code-quality mailing list > code-quality at python.org > https://mail.python.org/mailman/listinfo/code-quality > -------------- next part -------------- An HTML attachment was scrubbed... URL: From flavio at vinta.com.br Mon Jul 31 15:56:40 2017 From: flavio at vinta.com.br (=?UTF-8?Q?Fl=C3=A1vio_Juvenal?=) Date: Mon, 31 Jul 2017 16:56:40 -0300 Subject: [code-quality] I'm building a Pylint plugin to check for common Django bugs, would love some feedback Message-ID: Hi PyCQA! I'm building a Pylint plugin to check for common Django bugs. I already watched all Pylint/Astroid talks I could find and read a good amount of astroid/brain code, as well as code from existing Pylint plugins like pylint-django. However, since Astroid docs are sparse, I would appreciate some feedback on this plugin code. Code is here: https://github.com/vintasoftware/django-bug-finder/ Relevant parts are the checkers.py and the transforms.py . I've documented the non-trivial lines. For now, the plugin is just a proof of concept, very early stage, no unit-tests yet. I ran it against some large projects from my company; it seems to be working. I've implemented only two checks: - Check for not assigned queryset expressions. This is a common Django bug, since most queryset operations return an updated queryset clone and don't change the original one. - Check for Celery task calls that pass a model instance or a queryset as an argument. This is generally problematic because the model might suffer a concurrent update before the task is executed. For the checks to work properly, I had to fix the Astroid inference for Managers and QuerySets in transforms.py . This part is especially tricky, so I would love some feedback on this. If you know better ways to do what I'm doing there, please let me know. Cheers, Fl?vio. -- *Fl?vio Juvenal*Partner & Developer Hangout: flavio at vinta.com.br Skype: flaviojuvenal We design, develop and fix beautiful software. *http://www.vinta.com.br/ * -------------- next part -------------- An HTML attachment was scrubbed... URL: