llms.txt: machine-readable documentation index. Markdown version of this page is also available.

IntelliJ IDEA 2026.3 Help

Language Injection Settings dialog: Generic Python

Use this dialog to configure an injection rule that injects a language into Python string literals.

The dialog opens when you click the Add button Add on the Language Injections settings page and select Generic Python, or when you select a Python injection in the list and click the Edit button Edit.

Item

Description

Name

The name of the injection.

Language

The language to be injected.

  • ID: select the ID or the name of the language to be injected.

  • Prefix: specify a sequence of characters to be added before the corresponding string value.

  • Suffix: specify a sequence of characters to be added after the corresponding string value.

The prefix and suffix are optional.

Places Patterns

In this field, type the rules that define the context where you want IntelliJ IDEA recognize literals as injections.

In addition to the platform patterns, such as psiElement() and string(), you can use the following Python-specific patterns:

  • pyLiteralExpression(): matches a literal expression, such as a string literal.

  • pyStringLiteralMatches("regexp"): matches string literals whose value contains a match for the specified regular expression. The match is case-insensitive, and . also matches line breaks. Docstrings and string literals of 10,000 characters or more are not matched.

  • pyArgument("function_name", index): matches an argument of a call to a function or method with the specified name. index is the zero-based position of the argument. IntelliJ IDEA compares the function name with the name in the call and does not resolve the function.

  • pyModuleFunctionArgument("function_name", index, "module_name"): matches an argument of a call to a function that is defined at the top level of the specified module. module_name is the name of the module file without the extension, not the qualified name of the module. For example, for mypkg/db_utils.py, specify db_utils.

  • pyMethodArgument("method_name", index, "class_qualified_name"): matches an argument of a call to a method that is defined in the class with the specified qualified name. For an inherited method, specify the class that defines it. IntelliJ IDEA resolves the call by the inferred type of the object, so calls on objects of an unknown type are not matched.

The pyArgument(), pyModuleFunctionArgument(), and pyMethodArgument() patterns do not match keyword arguments, such as execute(sql="...").

To combine conditions, use .and().

Examples:

Inject a language into string literals that start with SELECT:

pyStringLiteralMatches("^\\s*SELECT\\s")

Inject a language into the first argument of any call to a function or method named execute:

pyLiteralExpression().and(pyArgument("execute", 0))

Inject a language into the first argument of the run_query() function defined in db_utils.py:

pyModuleFunctionArgument("run_query", 0, "db_utils")

Inject a language into the first argument of the query() method of the Repository class defined in myapp/db.py:

pyMethodArgument("query", 0, "myapp.db.Repository")

Multiple patterns

You can define multiple place patterns for a single injection rule. The injection activates if any of the patterns match (they are combined with OR logic). Add each pattern on a separate line.

Advanced

In this area, optionally specify additional settings to narrow the context where the injection rule is applicable and thus to enable more fine-grained control over the injection process.

  • Value patterntype a regular expression that determines the context to inject the language into. By using the first capturing group of the patterns as the target for injection, you can configure the procedure to have the language injected only into values that match a certain pattern or into multiple parts that match the pattern.

  • Single file - If the option is off, the fragments that match the value pattern are treated separately, as different "files" - for example from the fragment editor's viewpoint.

    If the option is on, the corresponding fragments are all merged together to form a single unit, or "file".

    Given the value pattern

    xxx (.+) yyy (.+) zzz

    and the fragment

    xxx select * yyy from family zzz,

    select * and from family are treated as two independent fragments (or "files") if the option is off. If the option is on, select * from family is treated as a single unit or "file".

14 October 2026