diff --git a/mypy/checker.py b/mypy/checker.py
--- a/mypy/checker.py
+++ b/mypy/checker.py
@@ -76,6 +76,7 @@
     AssignmentStmt,
     Block,
     BreakStmt,
+    BytesExpr,
     CallExpr,
     ClassDef,
     ComparisonExpr,
@@ -86,6 +87,7 @@
     EllipsisExpr,
     Expression,
     ExpressionStmt,
+    FloatExpr,
     ForStmt,
     FuncBase,
     FuncDef,
@@ -115,6 +117,7 @@
     ReturnStmt,
     StarExpr,
     Statement,
+    StrExpr,
     SymbolNode,
     SymbolTable,
     SymbolTableNode,
@@ -3849,6 +3852,23 @@ def inference_error_fallback_type(self, type: Type) -> Type:
         # we therefore need to erase them.
         return erase_typevars(fallback)
 
+    def simple_rvalue(self, rvalue: Expression) -> bool:
+        """Returns True for expressions for which inferred type should not depend on context.
+
+        Note that this function can still return False for some expressions where inferred type
+        does not depend on context. It only exists for performance optimizations.
+        """
+        if isinstance(rvalue, (IntExpr, StrExpr, BytesExpr, FloatExpr, RefExpr)):
+            return True
+        if isinstance(rvalue, CallExpr):
+            if isinstance(rvalue.callee, RefExpr) and isinstance(rvalue.callee.node, FuncBase):
+                typ = rvalue.callee.node.type
+                if isinstance(typ, CallableType):
+                    return not typ.variables
+                elif isinstance(typ, Overloaded):
+                    return not any(item.variables for item in typ.items)
+        return False
+
     def check_simple_assignment(
         self,
         lvalue_type: Type | None,
@@ -3870,6 +3890,30 @@ def check_simple_assignment(
             rvalue_type = self.expr_checker.accept(
                 rvalue, lvalue_type, always_allow_any=always_allow_any
             )
+            if (
+                isinstance(get_proper_type(lvalue_type), UnionType)
+                # Skip literal types, as they have special logic (for better errors).
+                and not isinstance(get_proper_type(rvalue_type), LiteralType)
+                and not self.simple_rvalue(rvalue)
+            ):
+                # Try re-inferring r.h.s. in empty context, and use that if it
+                # results in a narrower type. We don't do this always because this
+                # may cause some perf impact, plus we want to partially preserve
+                # the old behavior. This helps with various practical examples, see
+                # e.g. testOptionalTypeNarrowedByGenericCall.
+                with self.msg.filter_errors() as local_errors, self.local_type_map() as type_map:
+                    alt_rvalue_type = self.expr_checker.accept(
+                        rvalue, None, always_allow_any=always_allow_any
+                    )
+                if (
+                    not local_errors.has_new_errors()
+                    # Skip Any type, since it is special cased in binder.
+                    and not isinstance(get_proper_type(alt_rvalue_type), AnyType)
+                    and is_valid_inferred_type(alt_rvalue_type)
+                    and is_proper_subtype(alt_rvalue_type, rvalue_type)
+                ):
+                    rvalue_type = alt_rvalue_type
+                    self.store_types(type_map)
             if isinstance(rvalue_type, DeletedType):
                 self.msg.deleted_as_rvalue(rvalue_type, context)
             if isinstance(lvalue_type, DeletedType):

diff --git a/test-data/unit/check-inference-context.test b/test-data/unit/check-inference-context.test
--- a/test-data/unit/check-inference-context.test
+++ b/test-data/unit/check-inference-context.test
@@ -1419,3 +1419,60 @@ def bar(x: Union[Mapping[Any, Any], Dict[Any, Sequence[Any]]]) -> None:
     ...
 bar({1: 2})
 [builtins fixtures/dict.pyi]
+
+[case testOptionalTypeNarrowedByGenericCall]
+# flags: --strict-optional
+from typing import Dict, Optional
+
+d: Dict[str, str] = {}
+
+def foo(arg: Optional[str] = None) -> None:
+    if arg is None:
+        arg = d.get("a", "b")
+    reveal_type(arg)  # N: Revealed type is "builtins.str"
+[builtins fixtures/dict.pyi]
+
+[case testOptionalTypeNarrowedByGenericCall2]
+# flags: --strict-optional
+from typing import Dict, Optional
+
+d: Dict[str, str] = {}
+x: Optional[str]
+if x:
+    reveal_type(x)  # N: Revealed type is "builtins.str"
+    x = d.get(x, x)
+    reveal_type(x)  # N: Revealed type is "builtins.str"
+[builtins fixtures/dict.pyi]
+
+[case testOptionalTypeNarrowedByGenericCall3]
+# flags: --strict-optional
+from typing import Generic, TypeVar, Union
+
+T = TypeVar("T")
+def bar(arg: Union[str, T]) -> Union[str, T]: ...
+
+def foo(arg: Union[str, int]) -> None:
+    if isinstance(arg, int):
+        arg = bar("default")
+    reveal_type(arg)  # N: Revealed type is "builtins.str"
+[builtins fixtures/isinstance.pyi]
+
+[case testOptionalTypeNarrowedByGenericCall4]
+# flags: --strict-optional
+from typing import Optional, List, Generic, TypeVar
+
+T = TypeVar("T", covariant=True)
+class C(Generic[T]): ...
+
+x: Optional[C[int]] = None
+y = x = C()
+reveal_type(y)  # N: Revealed type is "__main__.C[builtins.int]"
+
+[case testOptionalTypeNarrowedByGenericCall5]
+from typing import Any, Tuple, Union
+
+i: Union[Tuple[Any, ...], int]
+b: Any
+i = i if isinstance(i, int) else b
+reveal_type(i)  # N: Revealed type is "Union[Any, builtins.int]"
+[builtins fixtures/isinstance.pyi]
diff --git a/test-data/unit/check-typeddict.test b/test-data/unit/check-typeddict.test
--- a/test-data/unit/check-typeddict.test
+++ b/test-data/unit/check-typeddict.test
@@ -893,7 +893,7 @@ B = TypedDict('B', {'@type': Literal['b-type'], 'b': int})
 
 c: Union[A, B] = {'@type': 'a-type', 'a': 'Test'}
 reveal_type(c) # N: Revealed type is "Union[TypedDict('__main__.A', {'@type': Literal['a-type'], 'a': builtins.str}), TypedDict('__main__.B', {'@type': Literal['b-type'], 'b': builtins.int})]"
-[builtins fixtures/tuple.pyi]
+[builtins fixtures/dict.pyi]
 
 [case testTypedDictUnionAmbiguousCase]
 from typing import Union, Mapping, Any, cast

Type narrowing failure inside `AsyncExitStack` blocks
**Bug Report**

In the following synchronous code, mypy is correctly able to perform type narrowing to determine that the `resource` variable must be an instance of `Resource` when `resource.do_thing()` is called inside the `foo()` function:

```python
from contextlib import AbstractContextManager
from typing import TypeVar
T = TypeVar("T")
Self = TypeVar("Self")

class ExitStack:
    def __enter__(self: Self) -> Self:
        return self
    def __exit__(self, *args: object) -> None:
        pass
    def enter_context(self, cm: AbstractContextManager[T]) -> T:
        return cm.__enter__()

class Resource:
    def __enter__(self: Self) -> Self:
        return self
    def __exit__(self, *args: object) -> None:
        pass
    def do_thing(self) -> None:
        pass

def foo(resource: Resource | None) -> None:
    with ExitStack() as stack:
        if resource is None:
            resource = stack.enter_context(Resource())
        resource.do_thing()
```

However, in an asynchronous version of this code, mypy is not able to narrow the type in the same way, leading to a false positive being emitted:

```python
from contextlib import AbstractAsyncContextManager
from typing import TypeVar
T = TypeVar("T")
Self = TypeVar("Self")

class AsyncExitStack:
    async def __aenter__(self: Self) -> Self:
        return self
    async def __aexit__(self, *args: object) -> None:
        pass
    async def enter_async_context(self, cm: AbstractAsyncContextManager[T]) -> T:
        return await cm.__aenter__()

class AsyncResource:
    async def __aenter__(self: Self) -> Self:
        return self
    async def __aexit__(self, *args: object) -> None:
        pass
    def do_thing(self) -> None:
        pass

async def async_foo(resource: AsyncResource | None) -> None:
    async with AsyncExitStack() as stack:
        if resource is None:
            resource = await stack.enter_async_context(AsyncResource())
        resource.do_thing()  # error: Item "None" of "Optional[AsyncResource]" has no attribute "do_thing"
```

Curiously, if we rewrite `async_foo()` like this, the false-positive error goes away:

```python
async def async_foo(resource: AsyncResource | None) -> None:
    async with AsyncExitStack() as stack:
        if resource is None:
            res = await stack.enter_async_context(AsyncResource())
            resource = res
        resource.do_thing()
```

**Real-life use case**

My use case is to write a function like this using `aiohttp`, in which a user can optionally supply an existing `aiohttp.ClientSession()` instance if they want to, or let the function create one on the fly if not.

```python
import aiohttp
from contextlib import AsyncExitStack

async def foo(session: aiohttp.ClientSession | None = None):
    async with AsyncExitStack() as stack:
        if session is None:
            session = await stack.enter_async_context(aiohttp.ClientSession())
        async with session.get("https://foo.com/json") as response:
            data = await response.json()
```

**To Reproduce**

https://mypy-play.net/?mypy=latest&python=3.10&gist=0ee494765b5abc08fc9f161bc63656a7

**Your Environment**

- Mypy version used: 0.982; also occurs on mypy master (commit 8d5b64140c5fe43a2e437e44a6bc3dfdb2b6948a)


```async def async_foo(resource: AsyncResource ) -> None:```
can we not remove the or operator here and later resource can be told if it is null
mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testLambdaInGenericClass mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testBasicContextInference mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testNestedListExpressions mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testEllipsisContextForLambda mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testRevealTypeContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testBasicContextInferenceForConstructor mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testEllipsisContextForLambda2 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testParenthesesAndContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testUnionWithGenericTypeItemContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testIncompatibleContextInference mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testLambdaNoneInContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testComplexTypeInferenceWithTuple mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferGenericLocalVariableTypeWithEmptyContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testUnionWithGenericTypeItemContextAndStrictOptional mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testIsinstanceInInferredLambda mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferLocalVariableTypeWithUnderspecifiedGenericType mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testMapWithOverloadedFunc mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testUnionWithGenericTypeItemContextInMethod mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testDictionaryLiteralInContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferMultipleLocalVariableTypesWithTupleRvalue mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testGenericMethodCalledInGenericContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInitializationWithInferredGenericType mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testOrOperationInferredFromContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferMultipleLocalVariableTypesWithArrayRvalueAndNesting mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testGenericMethodCalledInGenericContext2 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferredGenericTypeAsReturnValue mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testSomeTypeVarsInferredFromContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testLambdaDeferredCrash mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testIntersectionWithInferredGenericArgument mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferenceWithTypeVariableTwiceInReturnType mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testSomeTypeVarsInferredFromContext2 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferTypeVariableFromTwoGenericTypes1 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferenceWithAbstractClassContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testLambdaInListAndHigherOrderFunction mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferenceWithTypeVariableTwiceInReturnTypeAndMultipleVariables mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferenceWithAbstractClassContext2 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferTypeVariableFromTwoGenericTypes2 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testChainedAssignmentInferenceContexts mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferTypeVariableFromTwoGenericTypes3 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testMultipleTvatInstancesInArgs mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferenceWithAbstractClassContext3 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testContextForAttributeDeclaredInInit mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testNestedGenericFunctionCall1 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferTypeVariableFromTwoGenericTypes4 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferGenericTypeInAnyContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextSubClassBound mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testListMultiplyInContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferLambdaArgumentTypeUsingContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testNestedGenericFunctionCall2 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextSubClassBoundGenericReturn mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferLambdaReturnTypeUsingContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testUnionTypeContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testNestedGenericFunctionCall3 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextSubClassValues mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testIgnoringInferenceContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testMethodCallWithContextInference mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferLambdaTypeUsingContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextSubClassValuesGenericReturn mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testEmptyListExpression mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextSubclassBoundGeneric mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testStar2Context mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferLambdaAsGenericFunctionArgument mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testLambdaWithoutContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextSubclassBoundGenericCovariant mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testSingleItemListExpressions mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferenceInGenericFunction mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testLambdaContextVararg mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextNoArgsError mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testMultiItemListExpressions mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferenceInGenericClass mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInvalidContextForLambda mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testLambdaInGenericFunction mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testUseCovariantGenericOuterContext mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testLocalVariableInferenceFromEmptyList mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testUseCovariantGenericOuterContextUserDefined mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextSubclassValuesGeneric mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextSubclassValuesGenericCovariant mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testConditionalExpressionWithEmptyListAndUnionWithAny mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithClassOldVersion mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextUnionBound mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testConditionalExpressionWithEmptyIteableAndUnionWithAny mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictInstanceWithDictCall mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextUnionBoundGenericReturn mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferMultipleAnyUnionCovariant mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextUnionValues mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictWithClassOtherBases mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextUnionValuesGenericReturn mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferMultipleAnyUnionInvariant mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictWithDuplicateBases mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextOptional mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictInstanceWithDictLiteral mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testInferMultipleAnyUnionDifferentVariance mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextOptionalGenericReturn mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextOptionalMethod mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictWithClassWithOtherStuff mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextValuesOverlapping mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictInstanceWithNoArguments mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextOptionalTypeVarReturn mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictWithClassWithFunctionUsedToCrash mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextOptionalTypeVarReturnLambda mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextEmpty mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictInstanceWithUnknownArgumentPattern mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictWithDecoratedFunction mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testOptionalTypeNarrowedByGenericCall4 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextEmptyError mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testOptionalTypeNarrowedByGenericCall5 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testWideOuterContextNoArgs mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictWithClassmethodAlternativeConstructorDoesNotCrash mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictInstanceNonLiteralItemName mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictDoesNotAcceptsFloatForInt mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictInstanceWithKeywordArguments mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictTypeWithUnderscoreItemName mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictInstanceWithExtraItems mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAcceptsAnyType mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithClassOverwriting2 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithClassUnderscores mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictInstanceWithMissingItems mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictValueTypeContext mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanConvertTypedDictToItself mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictWithDuplicateKey1 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictInstanceWithIncompatibleItemType mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictWithDuplicateKey2 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanConvertTypedDictToEquivalentTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictInstanceWithInlineTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotConvertTypedDictToDictOrMutableMapping mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithClassOverwriting mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotConvertTypedDictToSimilarTypedDictWithNarrowerItemTypes mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithClass mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanConvertTypedDictToAny mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testJoinOfDisjointTypedDictsIsEmptyTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotConvertTypedDictToSimilarTypedDictWithWiderItemTypes mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithSubclass mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testAnonymousTypedDictInErrorMessages mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testJoinOfTypedDictWithCompatibleMappingIsMapping mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotConvertTypedDictToSimilarTypedDictWithIncompatibleItemTypes mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithSubclass2 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictWithSimpleProtocol mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testJoinOfTypedDictWithCompatibleMappingSupertypeIsSupertype mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanConvertTypedDictToNarrowerTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictClassEmpty mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictWithSimpleProtocolInference mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testJoinOfTypedDictWithIncompatibleTypeIsObject mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotConvertTypedDictToWiderTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictsWithNonTotal mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testJoinOfTypedDictHasOnlyCommonKeysAndNewFallback mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictsWithCompatibleCommonKeysHasAllKeysAndNewFallback mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanConvertTypedDictToCompatibleMapping mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictsWithNonTotalAndTotal mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testJoinOfTypedDictRemovesNonequivalentKeys mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotConvertTypedDictToIncompatibleMapping mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictsWithIncompatibleCommonKeysIsUninhabited mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictsWithIncompatibleNonTotalAndTotal mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictUnionSimplification mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictsWithNoCommonKeysHasAllKeysAndNewFallback mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAcceptsIntForFloatDuckTypes mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictConstraintsAgainstIterable mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictUnionSimplification2 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictWithCompatibleMappingIsUninhabitedForNow mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictMissingMethod mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictUnionUnambiguousCase mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanGetItemOfTypedDictWithValidStringLiteralKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictUnionAmbiguousCase mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictWithIncompatibleMappingIsUninhabited mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictChainedGetMethodWithDictFallback mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotGetItemOfTypedDictWithInvalidStringLiteralKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictDictLiterals mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testMeetOfTypedDictWithCompatibleMappingSuperclassIsUninhabitedForNow mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotGetItemOfAnonymousTypedDictWithInvalidStringLiteralKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictExplicitTypes mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictGetDefaultParameterStillTypeChecked mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotGetItemOfTypedDictWithNonLiteralKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictClassWithInvalidTotalArgument mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictChainedGetWithEmptyDictDefault mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateAnonymousTypedDictInstanceUsingDictLiteralWithExtraItems mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanSetItemOfTypedDictWithValidStringLiteralKeyAndCompatibleValueType mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictClassInheritanceWithTotalArgument mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictWithTotalTrue mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateAnonymousTypedDictInstanceUsingDictLiteralWithMissingItems mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotSetItemOfTypedDictWithIncompatibleValueType mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testNonTotalTypedDictInErrorMessages mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictWithInvalidTotalArgument mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotSetItemOfTypedDictWithInvalidStringLiteralKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testNonTotalTypedDictCanBeEmpty mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictGetMethod mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictWithTotalFalse mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotSetItemOfTypedDictWithNonLiteralKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithTooFewArguments mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictGetMethodTypeContext mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictConstructorWithTotalFalse mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictWithIsInstanceAndIsSubclass mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithTooManyArguments mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictInClassNamespace mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictGetMethodInvalidArgs mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictIndexingWithNonRequiredKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithInvalidName mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictInFunction mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithNonpositionalArgs mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictSubtypingWithTotalFalse mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithInvalidItems mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithInvalidItemName mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverloading6 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictJoinWithTotalFalse mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithKwargs mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithInvalidItemType mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testForwardReferenceInTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictClassWithTotalArgument mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithBytes mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotCreateTypedDictTypeWithInvalidName2 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testForwardReferenceInClassTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictWithImportCycleForward mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictNonMappingMethods mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testForwardReferenceToTypedDictInTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverloading mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictImportCycle mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictPopMethod mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testSelfRecursiveTypedDictInheriting mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAsStarStarArg mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverloading2 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictDel mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testSubclassOfRecursiveTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAsStarStarArgConstraints mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverloading3 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testPluginUnionsOfTypedDicts mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictForwardAsUpperBound mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAsStarStarArgCalleeKwargs mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithTypingProper mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverloading4 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testPluginUnionsOfTypedDictsNonTotal mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAsStarStarTwice mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCanCreateTypedDictWithTypingExtensions mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOptionalUpdate mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverloading5 mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAsStarStarAndDictAsStarStar mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictOverloadBad mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictNonTotalNonOverlapping mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictOverloadMappingBad mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictNonOverlapping mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictIsInstanceABCs mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictEmpty mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictOverloadNonStrKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictNonTotal mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictLiteralTypeKeyInCreation mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictNonTotalEmpty mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictIsInstance mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictTypeNarrowingWithFinalKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictNonStrKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotSubclassFinalTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictOverlapWithDictOverload mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictDoubleForwardMixed mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictDoubleForwardClass mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testCannotSubclassFinalTypedDictWithForwardDeclarations mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictCreatedWithEmptyDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testAssignTypedDictAsAttribute mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictUppercaseKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictDoubleForwardFunc mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictBytesKey mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAsUpperBoundAndIndexedAssign mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesRecognizeRequiredInTypedDictWithClass mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesOnlyAllowRequiredInsideTypedDictAtTopLevel mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesRecognizeRequiredInTypedDictWithAssignment mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testRequiredOnlyAllowsOneItem mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testRequiredExplicitAny mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesDisallowRequiredOutsideOfTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesDisallowRequiredInsideRequired mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesRecognizeNotRequiredInTypedDictWithClass mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesRecognizeNotRequiredInTypedDictWithAssignment mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesDisallowNotRequiredOutsideOfTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesOnlyAllowNotRequiredInsideTypedDictAtTopLevel mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testDoesDisallowNotRequiredInsideNotRequired mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testNotRequiredOnlyAllowsOneItem mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testNotRequiredExplicitAny mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictUnionGetItem mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictUnionSetItem mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictUnionDelItem mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testGenericTypedDictCreation mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictTypeVarUnionSetItem mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testGenericTypedDictExtending mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testGenericTypedDictExtendingErrors mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testGenericTypedDictInference mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictAttributeOnClassObject mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testGenericTypedDictMultipleGenerics mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testGenericTypedDictAlias mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testGenericTypedDictCallSyntax mypy/test/testcheck.py::TypeCheckSuite::check-typeddict.test::testTypedDictSelfItemNotAllowed
mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testOptionalTypeNarrowedByGenericCall mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testOptionalTypeNarrowedByGenericCall2 mypy/test/testcheck.py::TypeCheckSuite::check-inference-context.test::testOptionalTypeNarrowedByGenericCall3