github / github/codeql

LGTM.com - false positive for `sklearn.base.BaseEstimator._more_tags()`

Đang mở
#9,889 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
acknowledged false-positive Python
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

**Description of the false positive**
Using multiple base classes from `sklearn.base` together, e.g.,
```python
from sklearn.base import BaseEstimator, ClusterMixin

class Clustering(ClusterMixin, BaseEstimator):
...
```
LGTM identifies following error: `Base classes have conflicting values for attribute '_more_tags': Function _more_tags and Function _more_tags.`

I think that this is a false positive, because both functions `_more_tags` are used via the `inspect.getmro` function
```python
def _get_tags(self):
collected_tags = {}
for base_class in reversed(inspect.getmro(self.__class__)):
if hasattr(base_class, "_more_tags"):
# need the if because mixins might not have _more_tags
# but might do redundant work in estimators
# (i.e. calling more tags on BaseEstimator multiple times)
more_tags = base_class._more_tags(self)
collected_tags.update(more_tags)
return collected_tags
```
Checkout the [full definition](https://github.com/scikit-learn/scikit-learn/blob/baf0ea25d6dd034403370fea552b21a6776bef18/sklearn/base.py#L348-L357)

**URL to the alert on the project page on LGTM.com**
https://lgtm.com/projects/g/moldyn/MoSAIC/snapshot/c1df9c1a96a193a3e400986fb71b550bf0c42e2f/files/src/mosaic/clustering.py?sort=name&dir=ASC&mode=heatmap#x8e6a118dd37a8a7:1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.