PyDecoratorList (final String @NotNull ... decoratorTexts) { assert decoratorTexts.length > 0; StringBuilder functionText = new StringBuilder(); for (String decoText : decoratorTexts) { functionText.append(decoText).append("\n"); } functionText.append("def foo():\n\tpass"); final PyFunction function = createFromText(LanguageLevel.getDefault(), PyFunction.class, functionText.toString()); final PyDecoratorList decoratorList = function.getDecoratorList(); assert decoratorList != null; return decoratorList; }