Skip to content

TYP: fix np.random.{get,set}_bit_generator implicit re-exports (#32257) - #32291

Merged
charris merged 1 commit into
numpy:maintenance/2.5.xfrom
charris:backport-32257
Aug 14, 2026
Merged

TYP: fix np.random.{get,set}_bit_generator implicit re-exports (#32257)#32291
charris merged 1 commit into
numpy:maintenance/2.5.xfrom
charris:backport-32257

Conversation

@charris

@charris charris commented Aug 14, 2026

Copy link
Copy Markdown
Member

Backport of #32257.

At runtime, np.random re-exports get_bit_generator, yet it's not in np.random.__all__:

>>> import numpy as np
>>> np.random.get_bit_generator()
<numpy.random._mt19937.MT19937 object at 0x12ab85a0>
>>> "get_bit_generator" in np.random.__all__
False

The way to express this in the stubs is by using a redundant symbol alias (viz. import x as x), as specified in the Python typing spec: https://typing.python.org/en/latest/spec/distributing.html#import-conventions
Without this redundant alias (the current sitiation) accessing np.random.get_bit_generator will cause checkers to report an error:

image

No AI.

@charris charris added this to the 2.5.3 release milestone Aug 14, 2026
@charris
charris merged commit d84c587 into numpy:maintenance/2.5.x Aug 14, 2026
12 checks passed
@charris
charris deleted the backport-32257 branch August 14, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants