From bbc7c68d509f9affc9f732d3ed963d30eb09c5ff Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Fri, 29 Oct 2021 23:18:55 +0300 Subject: [PATCH 1/2] Make dummy classes constructible with any arguments --- python-package/lightgbm/compat.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/python-package/lightgbm/compat.py b/python-package/lightgbm/compat.py index 52726622f076..d5cd0ee3d2f1 100644 --- a/python-package/lightgbm/compat.py +++ b/python-package/lightgbm/compat.py @@ -14,12 +14,14 @@ class pd_Series: # type: ignore """Dummy class for pandas.Series.""" - pass + def __init__(self, *args, **kwargs): + pass class pd_DataFrame: # type: ignore """Dummy class for pandas.DataFrame.""" - pass + def __init__(self, *args, **kwargs): + pass concat = None is_dtype_sparse = None @@ -52,7 +54,8 @@ class pd_DataFrame: # type: ignore class dt_DataTable: # type: ignore """Dummy class for datatable.DataTable.""" - pass + def __init__(self, *args, **kwargs): + pass """sklearn""" @@ -98,17 +101,20 @@ def _check_sample_weight(sample_weight, X, dtype=None): class _LGBMModelBase: # type: ignore """Dummy class for sklearn.base.BaseEstimator.""" - pass + def __init__(self, *args, **kwargs): + pass class _LGBMClassifierBase: # type: ignore """Dummy class for sklearn.base.ClassifierMixin.""" - pass + def __init__(self, *args, **kwargs): + pass class _LGBMRegressorBase: # type: ignore """Dummy class for sklearn.base.RegressorMixin.""" - pass + def __init__(self, *args, **kwargs): + pass _LGBMLabelEncoder = None LGBMNotFittedError = ValueError @@ -143,19 +149,23 @@ class _LGBMRegressorBase: # type: ignore class Client: # type: ignore """Dummy class for dask.distributed.Client.""" - pass + def __init__(self, *args, **kwargs): + pass class dask_Array: # type: ignore """Dummy class for dask.array.Array.""" - pass + def __init__(self, *args, **kwargs): + pass class dask_DataFrame: # type: ignore """Dummy class for dask.dataframe.DataFrame.""" - pass + def __init__(self, *args, **kwargs): + pass class dask_Series: # type: ignore """Dummy class for dask.dataframe.Series.""" - pass + def __init__(self, *args, **kwargs): + pass From e974070c1cc899ff99479dc8487843d776029053 Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Sat, 30 Oct 2021 00:45:46 +0300 Subject: [PATCH 2/2] Update compat.py --- python-package/lightgbm/compat.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/python-package/lightgbm/compat.py b/python-package/lightgbm/compat.py index d5cd0ee3d2f1..1b58d256a651 100644 --- a/python-package/lightgbm/compat.py +++ b/python-package/lightgbm/compat.py @@ -101,20 +101,17 @@ def _check_sample_weight(sample_weight, X, dtype=None): class _LGBMModelBase: # type: ignore """Dummy class for sklearn.base.BaseEstimator.""" - def __init__(self, *args, **kwargs): - pass + pass class _LGBMClassifierBase: # type: ignore """Dummy class for sklearn.base.ClassifierMixin.""" - def __init__(self, *args, **kwargs): - pass + pass class _LGBMRegressorBase: # type: ignore """Dummy class for sklearn.base.RegressorMixin.""" - def __init__(self, *args, **kwargs): - pass + pass _LGBMLabelEncoder = None LGBMNotFittedError = ValueError