@Nullable
  private static PyType getTypeFromTarget(@NotNull PsiElement target,
                                          @NotNull TypeEvalContext context,
                                          @NotNull PyReferenceExpression anchor) {
    final PyType type = dropSelfForQualifiedMethod(getGenericTypeFromTarget(target, context, anchor), context, anchor);

    if (context.maySwitchToAST(anchor)) {
      final PyExpression qualifier = anchor.getQualifier();
      if (qualifier != null) {
        PyType qualifierType = context.getType(qualifier);
        boolean possiblyParameterizedQualifier = !(qualifierType instanceof PyModuleType || qualifierType instanceof PyImportedModuleType);
        if (possiblyParameterizedQualifier && PyTypeChecker.hasGenerics(type, context)) {
          final var substitutions =
            PyTypeChecker.unifyGenericCall(qualifier, Collections.emptyMap(), context);
          if (substitutions != null) {
            final PyType substituted = PyTypeChecker.substitute(type, substitutions, context);
            if (substituted != null) {
              return substituted;
            }
          }
        }
      }
    }

    return type;
  }
@Nullable
  private static PyType getTypeFromTarget(@NotNull PsiElement target,
                                          @NotNull TypeEvalContext context,
                                          @NotNull PyReferenceExpression anchor)