From 71b6550f11b557ab3626ff906cde3cfc340c09c2 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 29 Aug 2022 21:11:33 -0400 Subject: [PATCH] [python-package] add type hints on empty initializations (#5445) --- python-package/lightgbm/basic.py | 6 +++--- python-package/lightgbm/engine.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python-package/lightgbm/basic.py b/python-package/lightgbm/basic.py index bb707f61f07e..3004b95eaac1 100644 --- a/python-package/lightgbm/basic.py +++ b/python-package/lightgbm/basic.py @@ -2514,7 +2514,7 @@ def get_ref_chain(self, ref_limit: int = 100) -> Set["Dataset"]: Chain of references of the Datasets. """ head = self - ref_chain = set() + ref_chain: Set[Dataset] = set() while len(ref_chain) < ref_limit: if isinstance(head, Dataset): ref_chain.add(head) @@ -2733,8 +2733,8 @@ def __init__( ctypes.byref(self.handle))) # save reference to data self.train_set = train_set - self.valid_sets = [] - self.name_valid_sets = [] + self.valid_sets: List[Dataset] = [] + self.name_valid_sets: List[str] = [] self.__num_dataset = 1 self.__init_predictor = train_set._predictor if self.__init_predictor is not None: diff --git a/python-package/lightgbm/engine.py b/python-package/lightgbm/engine.py index 2cc050362d35..71e761ccf067 100644 --- a/python-package/lightgbm/engine.py +++ b/python-package/lightgbm/engine.py @@ -300,7 +300,7 @@ def __init__( model_file : str, pathlib.Path or None, optional (default=None) Path to the CVBooster model file. """ - self.boosters = [] + self.boosters: List[Booster] = [] self.best_iteration = -1 if model_file is not None: