-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong typing? #99
Comments
Thanks for the report. Could you please send me the error that Pyright is reporting? Thanks! |
@illagrenan here is my from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from typing import TYPE_CHECKING
import aiohttp
if TYPE_CHECKING:
from django_asgi_lifespan.types import State
@asynccontextmanager
async def lifespan_manager() -> AsyncGenerator["State", None]:
state: State = {
"aiohttp_client": aiohttp.ClientSession(),
}
try:
yield state
finally:
await state["aiohttp_client"].close() and here is my apps.py: from django.apps import AppConfig
from django_asgi_lifespan.register import register_lifespan_manager
from config.context import lifespan_manager
class CoreConfig(AppConfig):
name = "mybaze.core"
def ready(self):
register_lifespan_manager(
context_manager=lifespan_manager, # pyright: ignore [reportArgumentType] # https:/illagrenan/django-asgi-lifespan/issues/99
) Here is full error without suppression: P.s. Take my words with grain of salt - I'm not very experienced with complex type hinting in python yet. |
Thanks again for the report. You were right that the typing for LifespanManager was wrong. Originally, I didn't check the example codes using mypy, that's now fixed. I've released a new version, so you can check if Pyright is now OK. |
thanks! no complains anymore! |
That's great! Thanks! |
Following tutorial I saw that Pyright complains about typing. Indeed types are little different in runtime.
lifespan_manager is a simple callable up until it is called:
The text was updated successfully, but these errors were encountered: