Skip to content

Commit

Permalink
[python-package] make public API members explicit with module-level _…
Browse files Browse the repository at this point in the history
…_all__ variables (#5655)
  • Loading branch information
jameslamb authored Jan 12, 2023
1 parent e40c9e2 commit 23403a7
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
from .compat import PANDAS_INSTALLED, concat, dt_DataTable, pd_CategoricalDtype, pd_DataFrame, pd_Series
from .libpath import find_lib_path

__all__ = [
'Booster',
'Dataset',
'LGBMDeprecationWarning',
'LightGBMError',
'register_logger',
'Sequence',
]

_DatasetHandle = ctypes.c_void_p
_LGBM_EvalFunctionResultType = Tuple[str, float, bool]
_LGBM_BoosterEvalMethodResultType = Tuple[str, str, float, bool]
Expand Down
7 changes: 7 additions & 0 deletions python-package/lightgbm/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

from .basic import _ConfigAliases, _LGBM_BoosterEvalMethodResultType, _log_info, _log_warning

__all__ = [
'early_stopping',
'log_evaluation',
'record_evaluation',
'reset_parameter',
]

_EvalResultTuple = Union[
List[_LGBM_BoosterEvalMethodResultType],
List[Tuple[str, str, float, bool, float]]
Expand Down
2 changes: 2 additions & 0 deletions python-package/lightgbm/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,5 @@ def _LGBMCpuCount(only_physical_cores: bool = True):

def _LGBMCpuCount(only_physical_cores: bool = True):
return cpu_count()

__all__ = []
6 changes: 6 additions & 0 deletions python-package/lightgbm/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
_LGBM_ScikitEvalMetricType, _lgbmmodel_doc_custom_eval_note, _lgbmmodel_doc_fit,
_lgbmmodel_doc_predict)

__all__ = [
'DaskLGBMClassifier',
'DaskLGBMRanker',
'DaskLGBMRegressor',
]

_DaskCollection = Union[dask_Array, dask_DataFrame, dask_Series]
_DaskMatrixLike = Union[dask_Array, dask_DataFrame]
_DaskVectorLike = Union[dask_Array, dask_Series]
Expand Down
7 changes: 7 additions & 0 deletions python-package/lightgbm/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
_LGBM_CustomObjectiveFunction, _log_warning)
from .compat import SKLEARN_INSTALLED, _LGBMBaseCrossValidator, _LGBMGroupKFold, _LGBMStratifiedKFold

__all__ = [
'cv',
'CVBooster',
'train',
]


_LGBM_CustomMetricFunction = Callable[
[np.ndarray, Dataset],
Tuple[str, float, bool]
Expand Down
2 changes: 2 additions & 0 deletions python-package/lightgbm/libpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from platform import system
from typing import List

__all__ = []


def find_lib_path() -> List[str]:
"""Find the path to LightGBM library files.
Expand Down
8 changes: 8 additions & 0 deletions python-package/lightgbm/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
from .compat import GRAPHVIZ_INSTALLED, MATPLOTLIB_INSTALLED, pd_DataFrame
from .sklearn import LGBMModel

__all__ = [
'create_tree_digraph',
'plot_importance',
'plot_metric',
'plot_split_value_histogram',
'plot_tree',
]


def _check_not_tuple_of_2_elements(obj: Any, obj_name: str = 'obj') -> None:
"""Check object is not tuple or does not have 2 elements."""
Expand Down
7 changes: 7 additions & 0 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
dt_DataTable, pd_DataFrame)
from .engine import train

__all__ = [
'LGBMClassifier',
'LGBMModel',
'LGBMRanker',
'LGBMRegressor',
]

_LGBM_ScikitCustomObjectiveFunction = Union[
Callable[
[np.ndarray, np.ndarray],
Expand Down

0 comments on commit 23403a7

Please sign in to comment.