PyType (@NotNull TypeEvalContext context, @NotNull TypeEvalContext.Key key) { final PyFile file = PyUtil.as(FileContextUtil.getContextFile(this), PyFile.class); final PyBuiltinCache builtinCache = PyBuiltinCache.getInstance(file == null ? this : file); final LanguageLevel languageLevel = file == null ? LanguageLevel.forElement(this) : file.getLanguageLevel(); final ASTNode firstNode = ContainerUtil.getFirstItem(getStringNodes()); if (firstNode != null) { if (firstNode.getElementType() == PyElementTypes.FSTRING_NODE) { // f-strings can't have "b" prefix, so they are always unicode return builtinCache.getUnicodeType(languageLevel); } else if (firstNode.getElementType() == PyTokenTypes.DOCSTRING) { return builtinCache.getStrType(); } else if (((PyStringElement)firstNode).isBytes()) { return builtinCache.getBytesType(languageLevel); } final IElementType type = PythonHighlightingLexer.convertStringType(firstNode.getElementType(), firstNode.getText(), languageLevel, (file != null && file.hasImportFromFuture(FutureFeature.UNICODE_LITERALS))); if (PyTokenTypes.UNICODE_NODES.contains(type)) { return builtinCache.getUnicodeType(languageLevel); } } return builtinCache.getStrType(); }