I'm building a Pylint plugin to check for common Django bugs, would love some feedback
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 <https://github.com/vintasoftware/django-bug-finder/blob/master/django_bug_fi...> and the transforms.py <https://github.com/vintasoftware/django-bug-finder/blob/master/django_bug_fi...>. 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 <https://github.com/vintasoftware/django-bug-finder/blob/master/django_bug_fi...>. 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@vinta.com.br Skype: flaviojuvenal We design, develop and fix beautiful software. *http://www.vinta.com.br/ <http://www.vinta.com.br/>*
participants (1)
-
Flávio Juvenal