PD005 erroneously flags arithmetic methods from other packages
See original GitHub issueDescribe the bug
PD005 is triggered when any module has a method named something like .add()
To Reproduce
I noticed this while using the tarfile
module. The tarfile
module has a method named .add()
Here is the snippet. Flake8 triggered PD005 on both of the tar.add()
calls.
tar = tarfile.open(tar_filename, "w")
tar.add(other_filename) # <-- triggers PD005
for filename in filenames:
tar.add(filename) # <-- triggers PD005
tar.close()
Expected behavior
I expect this to only be triggered when a method like .add()
is called on a pandas
object.
Additional context I expect that this applies to the comparison operators too (PD006). Any fix for PD005 should also be made for PD006 too.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Math (Java Platform SE 8 ) - Oracle Help Center
The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric ...
Read more >RESEARCH J INC. - Bitsavers.org
CSP tried to read another record from $CS. Forward a system dump of the error to a Cray Research analyst. EXP. AB002 -...
Read more >Parkinsonian gait characterization and vibratory ... - ProQuest
Research suggests visual, auditory, and vibratory cueing methods may improve some ... In one email where he was helping me to understand another...
Read more >Introduction To Computers | PDF | Image Scanner | Computer ...
method alone or. Functional Units of the Computer Saves Time. Arithmetic Logical Unit (ALU) - Computers can perform complex calculations, thus
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Regarding the case for PD011 -
.values
, one check could be for the parentheses. I get a lot of false positives because I’m using both pandas and dictionaries. Looping through the values of the dictionary with.values()
triggers PD011.I’m not really familiar with the AST, so I don’t know if this is an easy check or not.
A quick hack (that could be optional for example) would be to check if pandas is imported in the file. Sure, it won’t work for a lot of cases, but for a lot of cases it also will work.