Skip to content

stdlib: audit more callback annotations - #8209

Merged
JelleZijlstra merged 7 commits into
masterfrom
stdlib-callables
Jul 19, 2022
Merged

JelleZijlstra merged 7 commits into
masterfrom
stdlib-callables

Conversation

@AlexWaygood

Copy link
Copy Markdown
Member

@AlexWaygood
AlexWaygood marked this pull request as ready for review June 29, 2022 22:49
@github-actions

This comment has been minimized.

Comment thread stdlib/shutil.pyi Outdated
@github-actions

This comment has been minimized.

Comment thread stdlib/shutil.pyi Outdated
Comment thread stdlib/shutil.pyi Outdated
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread stdlib/concurrent/futures/process.pyi Outdated
Comment thread stdlib/sched.pyi

__all__ = ["scheduler"]

_ActionCallback: TypeAlias = Callable[..., Any]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
_ActionCallback: TypeAlias = Callable[..., Any]
_ActionCallback: TypeAlias = Callable[..., object]

Looks like the return value is ignored

@AlexWaygood AlexWaygood Jul 19, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's used as an attribute annotation as well, though, and I wanted to avoid unexpected false positives on code like

e: Event
x = e.action()
x.foo()

I'm not sure if it makes sense to do that, but I didn't want to accidentally cause a regression. Same for _WriterCallback in wsgiref.validate.

Comment thread stdlib/shutil.pyi Outdated
def writelines(self, seq: Iterable[str]) -> None: ...
def close(self) -> NoReturn: ...

_WriterCallback: TypeAlias = Callable[[bytes], Any]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
_WriterCallback: TypeAlias = Callable[[bytes], Any]
_WriterCallback: TypeAlias = Callable[[bytes], object]

Return value is ignored

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

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

@JelleZijlstra
JelleZijlstra merged commit e2ce7c6 into master Jul 19, 2022
@JelleZijlstra
JelleZijlstra deleted the stdlib-callables branch July 19, 2022 14:07
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.

2 participants