Closed
Description
This is a follow up of #38594. When adding type hints to the sample
method, I ran into some problems for random_state
. The reason is that numpy < 1.17.0
does not have the random.Generator
class implemented. I tried to solve this with checking the numpy version with:
if np_version_under1p17:
RandomState = Union[int, ArrayLike, np.random.RandomState]
else:
RandomState = Union[int, ArrayLike, np.random.Generator, np.random.RandomState]
But this resulted in:
Cannot assign multiple types to name "RandomState" without an explicit "Type[...]" annotation [misc]
To solve this issue we have to add typing for random_state
.