-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / bindertopic-typed-dict
Description
from typing import Any, TypedDict
class _SessionData(TypedDict):
created: int
session: dict[str, Any]
class _EmptyDict(TypedDict):
"""Empty dict for typing."""
SessionData = _SessionData | _EmptyDict
data: SessionData
reveal_type(data)
a = data if data else None
reveal_type(a)
aiohttp_session/__init__.py:56: note: Revealed type is "Union[TypedDict('aiohttp_session._SessionData', {'created': builtins.int, 'session': builtins.dict[builtins.str, Any]}), TypedDict('aiohttp_session._EmptyDict', {})]"
aiohttp_session/__init__.py:58: note: Revealed type is "Union[TypedDict('aiohttp_session._EmptyDict', {}), None]"
I also get the same result if I make it not data
. The _SessionData
type just disappears for no reason and it keeps saying the empty dict will be the result regardless of the boolean check.
korompaiistvan
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / bindertopic-typed-dict