lamby / django-lint

Tool to lint Django applications and projects
http://chris-lamb.co.uk/projects/django-lint/
GNU General Public License v3.0
191 stars 30 forks source link

Can django-lint detect redundant fetches? #28

Open Milo-Lu opened 4 years ago

Milo-Lu commented 4 years ago

Can django-lint detects places where extra columns are retrieved, and provides suggestions of using values or values_list? Thanks

lamby commented 4 years ago

(By "extra" I assume you are meaning that they are retrieved but not used.) django-lint does not currently detect this but given that the underlying pylint tool can detect unused local variables then it might be possible to some degree but there would be so many false positives as model instances can be passed between modules... so, no, on balance I don't think this woud be a good thing to add.

Regarding using values_list etc. I would not recommend this approach as it moves you out of the world of Django into "raw" Python - I would use .only().