From 186d680a41a208808d26f1c5e37e48863d4715cc Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 10 Dec 2024 22:39:44 -0600 Subject: [PATCH] [python-package] remove unnecessary layer of try-catching in conditional imports --- python-package/lightgbm/__init__.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/python-package/lightgbm/__init__.py b/python-package/lightgbm/__init__.py index b679b3f665b5..b53d8176948c 100644 --- a/python-package/lightgbm/__init__.py +++ b/python-package/lightgbm/__init__.py @@ -10,21 +10,10 @@ # and its dependencies as early as possible from .basic import Booster, Dataset, Sequence, register_logger from .callback import EarlyStopException, early_stopping, log_evaluation, record_evaluation, reset_parameter +from .dask import DaskLGBMClassifier, DaskLGBMRanker, DaskLGBMRegressor from .engine import CVBooster, cv, train - -try: - from .sklearn import LGBMClassifier, LGBMModel, LGBMRanker, LGBMRegressor -except ImportError: - pass -try: - from .plotting import create_tree_digraph, plot_importance, plot_metric, plot_split_value_histogram, plot_tree -except ImportError: - pass -try: - from .dask import DaskLGBMClassifier, DaskLGBMRanker, DaskLGBMRegressor -except ImportError: - pass - +from .plotting import create_tree_digraph, plot_importance, plot_metric, plot_split_value_histogram, plot_tree +from .sklearn import LGBMClassifier, LGBMModel, LGBMRanker, LGBMRegressor _version_path = Path(__file__).absolute().parent / "VERSION.txt" if _version_path.is_file():