Skip to content

Commit a3be114

Browse files
Do not call getattr with a constant value
It is not any safer than normal property access. It feels like the intent might have been `hasattr()` instead of `getattr()`, but the initial commit e2086c3 appears to : - assume any attribute `dtype` is of type `numpy.dtype`, - test whether `numpy.dtype.names` is a list of fields names or `None`. https://numpy.org/doc/stable/reference/generated/numpy.dtype.names.html
1 parent 74885be commit a3be114

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tabulate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ def _normalize_tabular_data(tabular_data, headers, showindex="default"):
15231523
elif (
15241524
headers == "keys"
15251525
and hasattr(tabular_data, "dtype")
1526-
and getattr(tabular_data.dtype, "names")
1526+
and tabular_data.dtype.names
15271527
):
15281528
# numpy record array
15291529
headers = tabular_data.dtype.names

0 commit comments

Comments
 (0)