-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Labels
Typingtype annotations, mypy/pyright type checkingtype annotations, mypy/pyright type checking
Milestone
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.
Metadata
Metadata
Assignees
Labels
Typingtype annotations, mypy/pyright type checkingtype annotations, mypy/pyright type checking