B901 should not apply to __await__ methods
See original GitHub issueCustom awaitable objects need to implement __await__ generator methods with a return to provide values. B901 triggers on these for Python2 compatibility, but it is very unlikely that Python2 would use an __await__ method. The __await__ method must be an iterator, so using async def as suggested by B901 is not valid.
Marking every occurrence as # noqa: B901 is very annoying in an async library. Disabling it entirely is suboptimal, because a generator-return outside of __await__ usually hints at an error indeed.
def __await__(self) -> Generator[Any, Any, ST]:
return (yield from self._await_message().__await__())
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
c# - Should async method always call await, if not what is the ...
It seems that when the condition check is deferred, there is always a task being awaited, but when it's false in the handler,...
Read more >Async/Await - Best Practices in Asynchronous Programming
I'll explain the reasoning behind each guideline so that it's clear when it does and does not apply. The guidelines are summarized in...
Read more >flake8-bugbear - PyPI
A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.
Read more >Understanding Control Flow with Async and Await in C# ...
The await keyword does not block the current thread. What do we mean by that? Let's look at some examples of blocking code....
Read more >Async, Await, and ConfigureAwait – Oh My! | Core BTS Blog
To avoid this issue, you can use a method called ConfigureAwait with a false parameter. When you do, this tells the Task that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ah, I understand. Will fix.
I suppose that’s why
return xin a generator function behaves the way it does. TIL! When I got around to this behavior in other contexts it made no sense at all, but here it does.