Ref<PyType> (@NotNull PyFunction function, @NotNull PyCallSiteExpression callSite, @NotNull TypeEvalContext context) { String qualifiedName = function.getQualifiedName(); if (qualifiedName != null && PyCollectionTypeUtil.INSTANCE.getCollectionConstructors(LanguageLevel.forElement(callSite)).contains(qualifiedName)) { PyExpression target = PyCollectionTypeUtil.INSTANCE.getTargetForValueInAssignment(callSite); if (target instanceof PyTargetExpression element) { List<PyExpression> arguments = callSite.getArguments(null); List<PyType> argumentTypes = getTypesFromConstructorArguments(context, arguments); ScopeOwner owner = ScopeUtil.getScopeOwner(element); if (owner != null) { final List<PyType> typesByModifications = PyCollectionTypeUtil.INSTANCE.getCollectionTypeByModifications(qualifiedName, element, context); if (!typesByModifications.isEmpty()) { if (qualifiedName.equals(PyCollectionTypeUtil.DICT_CONSTRUCTOR)) { argumentTypes = extractTypesForDict(argumentTypes, typesByModifications); } else { argumentTypes.addAll(typesByModifications); argumentTypes = Collections.singletonList(PyUnionType.union(argumentTypes)); } final PyClass cls = function.getContainingClass(); if (cls != null) { return Ref.create(new PyCollectionTypeImpl(cls, false, argumentTypes)); } else { final PyType returnType = context.getReturnType(function); if (returnType instanceof PyClassType) { return Ref.create(new PyCollectionTypeImpl(((PyClassType)returnType).getPyClass(), false, argumentTypes)); } } } } } } return null; }