Skip to content

Conversation

@distortedsignal
Copy link

Recently I was writing some heavily-parallel code,
and I tried to type-check with mypy. I (naively)
thought that multiprocessing.Value was a class
and was very confused when mypy threw an error
on that line. I dropped into the interpreter and
tried to use the help function to find the
return type of Value - and failed. I dropped
into the code and found that the type returned
from the Value function was not exported from
the module.

I want types in Python to be awesome. I think
mypy is a step in the right direction for that.
This change is me doing my part to expose more
types so mypy can become as good as it can be.

@distortedsignal distortedsignal requested a review from tiran as a code owner October 3, 2023 17:54
@ghost
Copy link

ghost commented Oct 3, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Oct 3, 2023

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@distortedsignal
Copy link
Author

Reviewers: I didn't think this needed a GH Issue # b/c it's such a small change. I'm fine with exporting a different class, or masking this differently, but - to me - this seems like something that's obviously necessary. If this shouldn't go in, I'm fine with it not going in.

distortedsignal and others added 5 commits October 3, 2023 17:08
Recently I was writing some heavily-parallel code,
and I tried to type-check with `mypy`. I (naively)
thought that `multiprocessing.Value` was a class
and was very confused when `mypy` threw an error
on that line. I dropped into the interpreter and
tried to use the `help` function to find the
return type of `Value` - and failed. I dropped
into the code and found that the type returned
from the `Value` function was not exported from
the module.

I want types in Python to be _awesome_. I think
`mypy` is a step in the right direction for that.
This change is me doing my part to expose more
types so `mypy` can become as good as it can be.

distortedsignal<[email protected]>
@distortedsignal
Copy link
Author

Boop.

# Methods for getting synchronization wrappers
'Value', 'Array',
# The synchronization types
'Synchronized', 'SynchronizedArray', 'SynchronizedString',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not documented and therefore not properly public, why should they be added to __all__?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original context of the code I was writing is lost, but I feel like I covered it pretty well in the PR description. This is to make it easier to type multiprocessing code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(By which I mean use types with… not physically type on a keyboard)

@AA-Turner AA-Turner changed the title Add SynchronizedBase to __all__ Add SynchronizedBase to __all__ in multiprocessing.sharedctypes Aug 4, 2025
@@ -0,0 +1,4 @@
Export :class:`multiprocessing.Synchronized`,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this will have to be changed to a different file?

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