Skip to content

Inline Configuration

Inline configuration can be used to control Sourcery's behaviour directly in your source code.

Skip Comments

Skip comments tell Sourcery to skip refactoring a particular function.

Skip a specific refactoring

# sourcery skip: <refactoring-id>

Example

Sourcery finds two refactorings in the following code, assign-if-exp and inline-immediately-returned-variable. However, because of the comment # sourcery skip: inline-immediately-returned-variable, it will not propose the second refactoring.

def func(a, b):
    # sourcery skip: inline-immediately-returned-variable
    if a < b:
        min_value = a
    else:
        min_value = b
    c = min_value**2
    return c

Hint

Rule IDs are always provided whenever Sourcery suggests a change. You can browse a complete list at

Skip multiple refactorings

# sourcery skip: <rule-id>, <rule-id>, ...

Example

Sourcery finds two refactorings in the following code:

However, because of the comment # sourcery skip: assign-if-exp, inline-immediately-returned-variable, it will not propose either refactoring.

def func(a, b):
    # sourcery skip: assign-if-exp, inline-immediately-returned-variable
    if a < b:
        min_value = a
    else:
        min_value = b
    c = min_value**2
    return c

Hint

A # sourcery skip comment can be placed anywhere within a function

Skip all rules

# sourcery skip

Example

Because of the # sourcery skip comment in the following code, Sourcery will ignore this function completely.

def func(a, b):  # sourcery skip
    if a < b:
        min_value = a
    else:
        min_value = b
    c = min_value**2
    return c

Suppressing low code quality warnings

# sourcery skip: low-code-quality

Low code quality is a Comment (see low-code-quality). Because of this, it can be skipped like any other rule.

Example

def low_quality_function():  # sourcery skip: low-code-quality
    ...