Language Server version: v2020.9.0
Should not show Code is unreachable since the method being called is not awaited

without any await
import asyncio
class TestUnreachableCode:
@staticmethod
async def never_done_task():
while True:
await asyncio.sleep(0.01)
async def test_sould_not_show_unreachable_code(
self,
some_object
):
some_object.name = self.never_done_task()
print('') # <-- this code should not be marked as unreachable
using await keyword:
import asyncio
class TestUnreachableCode:
@staticmethod
async def never_done_task():
while True:
await asyncio.sleep(0.01)
async def test_sould_not_show_unreachable_code(
self,
some_object
):
some_object.name = await self.never_done_task()
print('') # <-- It's ok to mark this as unreachable code
Thanks for the bug report. You're correct that code after such a call should not be marked unreachable. I've disabled the NoReturn logic for all async functions, since it's often difficult or impossible to detect when the async function will execute. With the fix in place, neither of the above examples will report unreachable code. This fix will be in the next version of Pylance and Pyright.
Somewhat related... re: the latest Pylance changes (v2020.9.0)
Pylance still appears to be hinting Code is unreachable after calls to methods that had NoReturn and now (with the changes) return something else like Any.
I have the latest VSCode and Pylance as of writing.
@krooq, I'm not sure what you mean. If you think that there's a separate bug, please file a new issue and provide a sample. Thanks!
@krooq, I'm not sure what you mean. If you think that there's a separate bug, please file a new issue and provide a sample. Thanks!
Ticket raised here, it seems mostly unrelated to this ticket #334
Thanks for your attention @erictraut
This issue has been fixed in version 2020.9.4, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202094-10-september-2020