Skip to content

TYP: add RandomState alias #38860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
erfannariman opened this issue Dec 31, 2020 · 1 comment · Fixed by #42171
Closed

TYP: add RandomState alias #38860

erfannariman opened this issue Dec 31, 2020 · 1 comment · Fixed by #42171
Labels
Typing type annotations, mypy/pyright type checking
Milestone

Comments

@erfannariman
Copy link
Member

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.

@erfannariman erfannariman added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 31, 2020
@arw2019 arw2019 added Typing type annotations, mypy/pyright type checking and removed Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 1, 2021
@arw2019
Copy link
Member

arw2019 commented Jan 1, 2021

I'd change the title to TYP: add RandomState alias

(AFAIK enhancements are new feature implementations)

@erfannariman erfannariman changed the title ENH: add typing for RandomState TYP: add RandomState alias Jan 1, 2021
@jreback jreback modified the milestones: 1.3, 1.4 Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants