Skip to content

Releases: MarketSquare/robotframework-tidy

Robotidy 3.0

14 Jul 17:23
8ccc5e6

Choose a tag to compare

Major release of the Robotidy that brings long awaited align keywords and test cases transformers. This release also includes other improvements and bug fixes - read the changelog for the details. There are also backward incompatible changes (listed in Backward incompatible changes).

For more details see the full release notes.

Robotidy 2.6.0

17 Jun 13:40
fd44394

Choose a tag to compare

In this release we're focusing on fixing bugs with handling whitespace from the cli option and missing non-ascii characters from --diff output. There is also improvement to how IndentNestedKeyword handle nested keywords indentation in *** Settings *** section.

To upgrade to Robotidy 2.6.0 run following:

pip install -U robotframework-tidy

IndentNestedKeywords

The order of the transformers changed - now IndentNestedKeyword runs before AlignSettingsSection. Thanks for
this change settings will be properly indented by other transformers after IndentNestedKeyword splits the keywords (#318):

*** Settings ***
Suite Setup         Run Keywords
...                     No Operation
...                     No Operation

Fixes

  • Extended encoding (such as characters like ÁáÉéĚěÍíÓóÚúÝýŮůŘřŤťŠšĎČčŇň) is now supported in --diff mode (#324)
  • indent parameter is now taken into account by NormalizeTags transformer (#323)
  • spacecount parameter is now taken into account in inline IFs by NormalizeSeparators transformer (#322)

Acknowledgements

Thanks @Reddriver and Oli I'Anson (from slack channel #tidy) for raising bug issues & feature requests!

2.5.0

05 Jun 15:22
052653c

Choose a tag to compare

New release of the Robotidy: 2.5.0. In this release we have added new transformer (IndentNestedKeywords) and enhanced autoformatting in NormalizeNewLines. For more information read the details below.

To upgrade to Robotidy 2.5.0 run following:

pip install -U robotframework-tidy

Indent run keywords

New IndentNestedKeywords transformer for formatting whitespace in run keywords variants such as Run Keywords or
Run Keyword And Continue On Failure. It will result in transforming following code:

Run Keyword    Run Keyword If    ${True}    Run keywords   Log    foo    AND    Log    bar    ELSE    Log    baz

to:

Run Keyword
...    Run Keyword If    ${True}
...        Run keywords
...            Log    foo
...            AND
...            Log    bar
...    ELSE
...        Log    baz

Remove empty lines in multiline statements

NormalizeNewLines transformer now removes empty lines inside multiline statements. Such lines are allowed by Robot Framework but decrease readilibity:

*** Keywords ***
Keyword
    Keyword With
    ...  Multiline arguments

    ...  With empty lines

will be formatted to:

*** Keywords ***
Keyword
    Keyword With
    ...  Multiline arguments
    ...  With empty lines

2.4.1

02 Jun 08:24
fbea27a

Choose a tag to compare

Fix for SplitTooLongLine transformer breaking keywords with veeery long names (#314).

2.4.0

01 Jun 05:44
358aa60

Choose a tag to compare

Extra --indent option

Robotidy normalizes all whitespaces using the same fixed amount of spaces (configurable via --spacecount).
It's then optionally modified by various transformers such as AlignSettingsSection.
This release adds additional option --indent that allows to configure indentation separately (#293).

It's now possible to have for example indentation of 4, but separator between the tokens (spacecount) equal to 2 spaces:

robotidy --indent 4 --spacecount 2
Keyword
    FOR  ${index}  ${item}  IN ENUMERATE  @{LIST}
        My Keyword  ${index}  ${item}
    END

skip_documentation for NormalizeSeparators

It is now possible to skip formatting suite, test case and keyword documentation with NormalizeSeparator transformer
by using skip_documentation parameter (#300):

robotidy --configure NormalizeSeparators:skip_documentation=True src

This option is useful if you have custom formatting of the documentation that you don't want to lose when running the Robotidy.

Other

  • Added --skip-gitignore flag to ignore .gitignore files and parse files listed there (#299).

2.3.0

19 May 05:47
6e0fa1d

Choose a tag to compare

Prettified Robotidy output in the console from the help, desc and list commands:

image

2.2.0

26 Apr 18:20
f5347c9

Choose a tag to compare

In this release we're adding feature allowing to disable robotidy from source code and option to run robotidy with target Robot Framework version. Read the below description for more information and list of other changes.

Disable formatting from source code

Previously the only option to disable formatting in part of the file was to use cumbersome
--startline and --endline markers. This release brings new feature - comment disablers.
You can disable formatting in Robot Framework statement or in span of lines using # robocop: off marker.

To skip the formatting for one statement:

Keyword That Is Longer Than Allowed Line Length  ${arg}  # robotidy: off

To skip multiple lines:

*** Test Cases ***
Test that will be formatted
    Step

# robotidy: off
Test that will not be formatted
    Step

# robotidy: on
Another test that will be formatted
    Step

# robotidy: on marker is used to enable the formatting again - but is not required. # robotidy: off will disable
the formatting to the end of the current block:

Keyword That Is Formatted
IF    $condition
    Formatted
ELSE
    Formatted
    # robotidy: off
    Not Formatted
    WHILE    $condition
        Not Formatted
    END
END
Formatted

It's possible to disable the formatting in whole file by putting # robotidy: off on first line:

# robotidy: off
*** Settings ***
Library    Collections

You can also disable the formatting in whole section if you put # robotidy: off in section header:

*** Test Cases ***
Formatted
    Step

*** Keywords ***  # robotidy: off
Not Formatted
    Step

Transformers

  • NormalizeNewLines now removes leading, trailing and consecutive empty lines in IF, FOR, WHILE, TRY EXCEPT blocks (#288)

Fixes

  • It's no longer possible to forcefully enable transformer not supported in installed Robot Framework version (#281, #283)

Other

  • You can now disable coloring the output with --no-color cli option or by setting $NO_COLOR environment variable (#268)
  • Added an option to set target version of Robot Framework when formatting the files:
    robotidy --target-version rf4 .
    
    It will disable all transformers that require Robot Framework greater than to run (even if you have Robot Framework greater than installed). (#253)

Acknowledgements

Thanks @DrVanScott, @Ga22be, @westadejl and @IlfirinPL for raising bug issues & feature requests!

2.1.1

12 Apr 13:27
03e142f

Choose a tag to compare

Fix release addressing a bug where *** Tasks *** were normalized to *** Test Cases *** by NormalizeSectionHeaderName (#279).

Acknowledgements

Thanks @fabioz for finding and fixing the issue!

2.1.0

24 Mar 21:54
69e407e

Choose a tag to compare

Minor update with major change - standarized the empty lines count between sections in Robotidy and Robocop tool.

Transformers

Updated NormalizeNewLines to separate sections by two empty lines (instead of one). It's effort of normalizing
Robocop output (which suggest to use 2 empty lines) and Robotidy (which previously transformed with 1 empty line) (#536).

Previously:

*** Settings ***
Force Tags    tag

*** Test Cases ***
Test
    No Operation

Now:

*** Settings ***
Force Tags    tag


*** Test Cases ***
Test
    No Operation

If you wish to retain previous behaviour you can configure it:

robotidy --configure NormalizeNewLines:section_lines=1 <src>

or from configuration file:

[tool.robotidy]
configure = [
    "NormalizeNewLines : section_lines = 1"
]

Other

Add missing packaging dependency (#275)

Acknowledgements

Big thanks to @bollwyvl for detecting and fixing missing packaging dependency (and improving our requirements in general)

2.0.0

24 Mar 12:07
8ff6520

Choose a tag to compare

Robotidy 2.0

Major release of Robotidy that brings new transformers and features. It focuses on bringing support for
Robot Framework 5.0 new syntax such as BREAK, CONTINUE, RETURN statements or TRY EXCEPT block.
Also Robotidy documentation got several improvements and extra examples.

New Transformers

ReplaceReturns

Replaces return statements (such as [Return] setting or Return From Keyword keyword) with RETURN statement (#231).

Following code:

*** Keywords ***
Keyword
    Return From Keyword If    $condition    2
    Sub Keyword
    [Return]    1

Keyword 2
    Return From Keyword    ${arg}

will be transformed to:

*** Keywords ***
Keyword
    IF    $condition
        RETURN    2
    END
    Sub Keyword
    RETURN    1

Keyword 2
    RETURN    ${arg}

See https://robotidy.readthedocs.io/en/latest/transformers/ReplaceReturns.html for more examples

ReplaceBreakContinue

Replaces Continue For Loop and Exit For Loop keyword variants with CONTINUE and BREAK statements (#241).

Following code:

*** Keywords ***
Keyword
    FOR    ${var}    IN  1  2
        Continue For Loop
        Continue For Loop If    $condition
        Exit For Loop
        Exit For Loop If    $condition
    END

will be transformed to:

*** Keywords ***
Keyword
    FOR    ${var}    IN  1  2
        CONTINUE
        IF    $condition
            CONTINUE
        END
        BREAK
        IF    $condition
            BREAK
        END
    END

See https://robotidy.readthedocs.io/en/latest/transformers/ReplaceBreakContinue.html for more examples.

InlineIf

Replaces IF blocks with inline IF (#230).

Following code::

*** Test Cases ***
Test
    IF    $condition1
        Keyword    argument
    END
    IF    $condition2
        ${var}  Keyword
    ELSE
        ${var}  Keyword 2
    END
    IF    $condition1
        Keyword    argument
        Keyword 2
    END

will be transformed to:

*** Test Cases ***
Test
    IF    $condition1    Keyword    argument
    ${var}    IF    $condition2    Keyword    ELSE    Keyword 2
    IF    $condition1
        Keyword    argument
        Keyword 2
    END

You can decide to not replace IF blocks containing ELSE or ELSE IF branches by setting skip_else to True.

See https://robotidy.readthedocs.io/en/latest/transformers/InlineIf.html for more examples.

Changes in transformers

min_width parameter

New min_width parameter was added to AlignSettingsSection, AlignVariablesSection and AlignTestCases (#242).
It allows to set minimal width of data column instead of using width of the widest argument in the column.

Following code:

*** Variables ***
${var}    a
${var2}  b

would be aligned to ${var2} length since it's the longest token. If you wish to have fixed width you can use
min_width parameter:

robotidy --configure AlignVariablesSection:min_width=15

With such configuration previous code will be transformed to:

*** Variables ***
${var}         a
${var2}        b

Sections only with comments

Previously, sections that contained only comments and empty lines were removed by default by DiscardEmptySections. It
could be changed by configuring allow_only_comments to True. Since it wasn't expected behaviour by most users, now it
works in an opposite way - only the sections with comments will be removed by configuring allow_only_comments to False (#235).

Do not align variables with given types

New skip_types parameter in AlignVariablesSection which allows to not align variables of particular type (#225)

With following configuration:

    robotidy --configure AlignVariablesSection:skip_types=dict

All variables except dictionaries will be aligned.

SplitTooLongLine transformer

Several updates to SplitTooLongLine transformer.


Basic behaviour changed and now every statement that's longer than
character limit will be split to multiple lines:

Keyword With Longer Name
...    ${arg1}
...    ${arg2}
...    ${arg3}

If you wish to use previous algorithm of feeding arguments into one line until limit set split_on_every_arg to False:

Keyword With Longer Name    ${arg1}  # let's asumme that ${arg} is right below character limit
...    ${arg2}    ${arg3}

Assignments are now split (if they don't fit in one line):

${first_assignment}
...    ${second_assignment}
...    ${third_assignment}
...    Some Lengthy Keyword So That This Line Is Too Long And Bit Over

RenameKeywords transformer

Library names are now by default ignored by RenameKeywords transformer. Previously, it could result in an unexpected behaviour (#269).
If you want to transform library names pass ignore_library=False to transformer.

    custom_library.Keyword  # custom_library will be renamed to Custom Library only if you set `ignore_library` to False
    Other Keyword

Other

Overwrite files with --check flag

It is now possible to force overwrite with --check and --overwrite flags (#239).
Going over possible options:

Transform the files and return 0 even if there were files transformed.

robotidy src

Don't transform the files and return 0 even if there would be files transformed

robotidy --no-overwrite src

Don't transform the files and return 1 if there would be files transformed

robotidy --check src

Transform the files and return 1 if there are files transformed

robotidy --check --overwrite src

User-friendly exceptions

Changed exceptions to be more user-friendly. Robotidy will try to recognize common mistakes.
For unknown issues there is an extra message with link to our bug board (#250)

Previously, typos or common mistakes resulted in an error stack being printed - often without clear information what went wrong.
Now Robotidy tries to output the reason of a failure:

> robotidy --transform InlineI:line_length=100 .
Error: Importing transformer 'InlineI' failed. Verify if correct name or configuration was provided. Did you mean:
    InlineIf

> robotidy --diff --transform InlineIf:line-len=100 .
Error: InlineIf: Failed to import. Verify if correct name or configuration was provided. This transformer accepts following arguments:
    line_length
    skip_else

> robotidy --diff --transform InlineIf:line_lengthn=abc .
Error: InlineIf: Failed to import. Verify if correct name or configuration was provided. 
Argument 'line_length' got value 'abc' that cannot be converted to integer or None.

Changes to acceptance tests

Refactored Robotidy acceptance tests (#248).

Fixes

  • Unmodified files are now not saved to the disk (#237)

Acknowledgements

Thanks @DetachHead and @ealap for reporting issues and ideas.