tophat / codewatch

[deprecated] Monitor and manage deeply customizable metrics about your python code using ASTs
https://codewatch.io
Apache License 2.0
38 stars 3 forks source link

Infer on `.expr` when `Call` node has `.attrname` #35

Closed cabiad closed 5 years ago

cabiad commented 5 years ago

In Django, models have a .objects attribute (of type django.models.Manager) that can be inferred when accessed (as the .func.expr in a Call node), but attempting to infer on the .func directly fails. This doesn't happen with other nested attributes, but is due to some "special Django magic" (which I haven't yet dug into).

This change works around the behaviour in Django by inferring in the place that works then reconstructing the full qname.

codecov[bot] commented 5 years ago

Codecov Report

Merging #35 into master will increase coverage by 0.04%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #35      +/-   ##
==========================================
+ Coverage   96.88%   96.92%   +0.04%     
==========================================
  Files           8        8              
  Lines         289      293       +4     
  Branches       36       37       +1     
==========================================
+ Hits          280      284       +4     
  Misses          5        5              
  Partials        4        4
Flag Coverage Δ
#py27 96.92% <100%> (+0.04%) :arrow_up:
#py36 96.92% <100%> (+0.04%) :arrow_up:
Impacted Files Coverage Δ
codewatch/node_visitor.py 88.15% <100%> (+0.65%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 74c5b03...1184ed3. Read the comment docs.