Skip to content

Fix set annotations in concurrent.futures._base - #6034

Merged
Akuli merged 2 commits into
python:masterfrom
srittau:concurrent-futures
Sep 14, 2021
Merged

Akuli merged 2 commits into
python:masterfrom
srittau:concurrent-futures

Conversation

@srittau

@srittau srittau commented Sep 14, 2021

Copy link
Copy Markdown
Collaborator

Fixes #6033

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

optuna (https://github.com/optuna/optuna.git)
- optuna/study/_optimize.py:103: error: Incompatible types in assignment (expression has type "AbstractSet[Future[Any]]", variable has type "Set[Future[Any]]")

def __new__(_cls, done: Set[Future[_T]], not_done: Set[Future[_T]]) -> DoneAndNotDoneFutures[_T]: ...
done: set[Future[_T]]
not_done: set[Future[_T]]
def __new__(_cls, done: set[Future[_T]], not_done: set[Future[_T]]) -> DoneAndNotDoneFutures[_T]: ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should done and not_done be mutable, so that users can add or remove futures from them? collections.abc.Set is immutable and would prevent that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

They are set in the implementation and mutable.

@Akuli
Akuli merged commit ca38856 into python:master Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recent change to concurrent/futures/_base.pyi broke a bunch of code

2 participants