question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PD005 erroneously flags arithmetic methods from other packages

See original GitHub issue

Describe 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:open
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gahjellecommented, Feb 5, 2020

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.

1reaction
wanaryytelcommented, Oct 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found