graphistry / pygraphistry

PyGraphistry is a Python library to quickly load, shape, embed, and explore big graphs with the GPU-accelerated Graphistry visual graph analyzer
BSD 3-Clause "New" or "Revised" License
2.09k stars 206 forks source link

[BUG] feature_utils unit tests failing mypy #574

Open lmeyerov opened 3 days ago

lmeyerov commented 3 days ago

Describe the bug

Regular PR fails on mypy analysis of feature_utils: https://github.com/graphistry/pygraphistry/actions/runs/9800176651/job/27061697437?pr=573

PyGraphistry API client environment

Additional context

+ mypy --config-file mypy.ini graphistry
graphistry/feature_utils.py:39: error: Cannot assign to a type  [misc]
graphistry/feature_utils.py:39: error: Incompatible types in assignment (expression has type "object", variable has type "Type[SentenceTransformer]")  [assignment]

=>

https://github.com/graphistry/pygraphistry/blob/53448d4ef153fd262466087a951bc28a44c8fadf/graphistry/feature_utils.py#L39

on


if TYPE_CHECKING:
    MIXIN_BASE = ComputeMixin
    try:
        from sklearn.pipeline import Pipeline
    except:
        Pipeline = Any
    try:
        from sentence_transformers import SentenceTransformer
    except:
        SentenceTransformer = Any
    try:
        from dirty_cat import (
            SuperVectorizer,
            GapEncoder,
            SimilarityEncoder,
        )
    except:
        SuperVectorizer = Any
        GapEncoder = Any
        SimilarityEncoder = Any
    try:
        from sklearn.preprocessing import FunctionTransformer
        from sklearn.base import BaseEstimator, TransformerMixin
    except:
        FunctionTransformer = Any
        BaseEstimator = object
        TransformerMixin = object
else:
    MIXIN_BASE = object
    Pipeline = Any
    SentenceTransformer = Any
    SuperVectorizer = Any
    GapEncoder = Any
    SimilarityEncoder = Any
    FunctionTransformer = Any
    BaseEstimator = Any
    TransformerMixin = Any

@tanmoyio @mj3cheun @silkspace can one of you take?

dcolinmorgan commented 3 days ago

maybe something here ?