Skip to content

Instantly share code, notes, and snippets.

@lmazuel
Created March 11, 2025 16:59
Show Gist options
  • Save lmazuel/e168c311c4f3df6520b5c05bc644d6ed to your computer and use it in GitHub Desktop.
Save lmazuel/e168c311c4f3df6520b5c05bc644d6ed to your computer and use it in GitHub Desktop.
Pylint rules

do-not-import-asyncio

Summary

Rule codename: do-not-import-asyncio Rule number: 666

Description

You should not, because trio

Example

# This is simple, do not import asyncio :)
import asyncio

How to fix it

If you use it for asyncio.sleep, then you should access your transport. For instance, inside of a policy

class Mypolicy
   async def on_request(self, request):
      await request.context.transport.sleep(666)

If not sleep, or not a policy, at least import it locally and suppress the warning:

async def sommething():
   import asyncio
   asyncio.Lock()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment