GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add aliases for 'function classes' to multiprocessing by srittau · Pull Request #5346 · python/typeshed

Conversation

@srittau

@srittau srittau commented May 5, 2021

Copy link
Copy Markdown
Collaborator

Part of #4313

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@srittau
Add aliases for 'function classes' to multiprocessing
4f9663b
Part of python#4313
@github-actions

github-actions Bot commented May 5, 2021

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@srittau
typo
3854897
@github-actions

github-actions Bot commented May 5, 2021

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Akuli

Akuli commented May 6, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

I'm still not sure if we should do this. Even though lies in typeshed often result in problems, I think this is more of a "practicality beats purity" case, as being able to use multiprocessing.Event or multiprocessing.Queue as a type annotation has several advantages:

  • It is what users of typeshed expect. This is important. Even though they aren't types at runtime, that likely isn't a problem in practice. For example, isinstance(some_object, multiprocessing.Queue) errors every time, instead of silently doing the wrong thing. Also, isinstance checks like that are much less common than type annotations.
  • Not-what-you-would-expect things need documentation. A comment somewhere in typeshed's stub files does not suffice, and we don't really have a good place where the documentation would go.
  • Type checkers don't give a good error message for using a function as a type annotation. If you should use multiprocessing._Event as the type annotation instead of multiprocessing.Event, then the error message you get when using multiprocessing.Event should clearly say so. But it doesn't. It should either explain the situation or point to the documentation, wherever it would be.
hauntsaninja reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@srittau

srittau commented May 6, 2021

Copy link
Copy Markdown
Collaborator Author

I'm strongly opposed to introducing more lies, especially in this case. For example, IDEs will report wrong signatures and the following will not report an error, but will fail at runtime:

from multiprocessing import Queue
class MyQueue(Queue): ...

There are probably more problems with lying, and often these problems are subtle and hard to spot for someone not knowing what's going on. On the other hand, using foo: Queue = Queue() is an immediate error and investigating that error will lead the use to the stubs and the correct solution.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Akuli Akuli mentioned this pull request May 7, 2021
Functions that are actually classes #5145
Closed
@JelleZijlstra
JelleZijlstra merged commit a7302dc into python:master May 16, 2021
@srittau
srittau deleted the multiprocessing-aliases branch May 16, 2021 19:53
@Akuli Akuli mentioned this pull request Jul 31, 2022
Remove, move or # noqa more TypeAlias declarations #8450
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@srittau @Akuli @JelleZijlstra
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.