PY-36444 Remove @contextlib.contextmanager from PyKnownDecoratorUtil.KnownDecorator

This decorator is fully type hinted in Typeshed, so, with the changes introduced
for PY-60104, it's no longer necessary to special-case it anywhere.
PyDecoratedFunctionTypeProvider can infer the correct type after application
of this decorator to a generator function just as for any other typed decorator.

The original problem was caused by the fact that PyDecoratedFunctionTypeProvider
didn't process declarations having any decorator listed in the KnownDecorator enum,
as presumably all of them were too "magical" to analyze.

Co-authored-by: Daniil Kalinin <daniil.kalinin@jetbrains.com>

GitOrigin-RevId: 53b277803a1eb42784131d0dae5bb7ace173c017
This commit is contained in:
Mikhail Golubev
2023-12-01 18:34:16 +02:00
committed by intellij-monorepo-bot
parent 9300fe8c45
commit fa168f4a00
5 changed files with 36 additions and 7 deletions

View File

@@ -37,8 +37,6 @@ public final class PyKnownDecoratorUtil {
CLASSMETHOD(PyNames.CLASSMETHOD),
PROPERTY(PyNames.PROPERTY),
CONTEXTLIB_CONTEXTMANAGER("contextlib.contextmanager"),
FUNCTOOLS_LRU_CACHE("functools.lru_cache"),
FUNCTOOLS_WRAPS("functools.wraps"),
FUNCTOOLS_TOTAL_ORDERING("functools.total_ordering"),
@@ -241,12 +239,12 @@ public final class PyKnownDecoratorUtil {
return true;
}
return ContainerUtil.exists(decorators, d -> d == UNITTEST_MOCK_PATCH || d == CONTEXTLIB_CONTEXTMANAGER);
return ContainerUtil.exists(decorators, d -> d == UNITTEST_MOCK_PATCH);
}
public static boolean hasChangingReturnTypeDecorator(@NotNull PyDecoratable decoratable, @NotNull TypeEvalContext context) {
final List<KnownDecorator> decorators = getKnownDecorators(decoratable, context);
return ContainerUtil.exists(decorators, d -> d == UNITTEST_MOCK_PATCH || d == CONTEXTLIB_CONTEXTMANAGER);
return ContainerUtil.exists(decorators, d -> d == UNITTEST_MOCK_PATCH);
}
public static boolean hasUnknownOrUpdatingAttributesDecorator(@NotNull PyDecoratable decoratable, @NotNull TypeEvalContext context) {