Repository: deppen8/pandas-vet

Issue:
inplace set to a variable raises exception
**Describe the bug**
raised exception

**To Reproduce**
Steps to reproduce the behavior:

Have the following code in a file

```python
def some_function(dataFrame, in_place=False):
    return dataFrame.drop([], inplace=in_place)
```

**Expected behavior**
Allow `flake8` to report violations and not throw exceptions.

**Screenshots**
<img width="732" alt="Screen Shot 2021-09-11 at 11 42 54 AM" src="https://user-images.githubusercontent.com/82820859/132955083-596471df-a18d-4b6d-b45b-afbdaae3596d.png">

**Additional context**

```
bash-5.1# cat /usr/lib/python3.9/site-packages/pandas_vet/version.py 
__version__ = "0.2.2"
```

This is running on a docker container based on alpine:3.14.1. Same results obtained on a mac.

Things work if we do not provide a variable:

```python
def some_function(dataFrame, in_place=False):
    return dataFrame.drop([], inplace=False)
```



Discussion:

Patch:
diff --git a/src/pandas_vet/__init__.py b/src/pandas_vet/__init__.py
index 9060511..2a4f0e0 100644
--- a/src/pandas_vet/__init__.py
+++ b/src/pandas_vet/__init__.py
@@ -173,7 +173,11 @@ def check_inplace_false(node: ast.Call) -> List:
     """
     errors = []
     for kw in node.keywords:
-        if kw.arg == "inplace" and kw.value.value is True:
+        if (
+            kw.arg == "inplace"
+            and hasattr(kw.value, "value")
+            and kw.value.value is True
+        ):
             errors.append(PD002(node.lineno, node.col_offset))
     return errors
 


Test patch:
diff --git a/tests/test_PD002.py b/tests/test_PD002.py
index 7034674..f34fb1b 100644
--- a/tests/test_PD002.py
+++ b/tests/test_PD002.py
@@ -24,3 +24,16 @@ def test_PD002_fail():
     actual = list(VetPlugin(tree).run())
     expected = [PD002(1, 0)]
     assert actual == expected
+
+
+def test_PD002_with_variable_does_not_crash():
+    """
+    Test that using inplace=<some variable> does not raise Exceptions.
+
+    It will not be able to infer the value of the variable, so no errors either.
+    """
+    statement = """use_inplace=True; df.drop(['a'], axis=1, inplace=use_inplace)"""
+    tree = ast.parse(statement)
+    actual = list(VetPlugin(tree).run())
+    expected = []
+    assert actual == expected