Ref<PyType> (@NotNull PyNamedParameter param, @NotNull PyFunction func, @NotNull Context context) { @Nullable PyExpression typeHint = getAnnotationValue(param, context.myContext); if (typeHint == null) { String paramTypeCommentHint = param.getTypeCommentAnnotation(); if (paramTypeCommentHint != null) { typeHint = toExpression(paramTypeCommentHint, param); } } if (typeHint == null) { PyFunctionTypeAnnotation annotation = getFunctionTypeAnnotation(func); if (annotation != null) { PyExpression funcTypeCommentParamHint = findParamTypeHintInFunctionTypeComment(annotation, param, func); if (funcTypeCommentParamHint == null) { return Ref.create(); } typeHint = funcTypeCommentParamHint; } } if (typeHint == null) { return null; } if (typeHint instanceof PyReferenceExpression ref && ref.isQualified() && ( param.isPositionalContainer() && "args".equals(ref.getReferencedName()) || param.isKeywordContainer() && "kwargs".equals(ref.getReferencedName()) )) { typeHint = Objects.requireNonNull(ref.getQualifier()); } PyType type = Ref.deref(getType(typeHint, context)); if (param.isPositionalContainer() && !(type instanceof PyParamSpecType)) { return Ref.create(PyTypeUtil.toPositionalContainerType(param, type)); } if (param.isKeywordContainer() && !(type instanceof PyParamSpecType)) { return Ref.create(PyTypeUtil.toKeywordContainerType(param, type)); } if (PyNames.NONE.equals(param.getDefaultValueText())) { return Ref.create(PyUnionType.union(type, PyNoneType.INSTANCE)); } return Ref.create(type); }