From Robotidy 3.0 see release notes in docs/releasenote
directory.
- Robotidy transformers now inherits from
Transformer
core class (instead ofModelTransformer
).ModelTransformer
will be still supported in external transformers, however theTransformer
will provide more utility over the time.
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
- Extended encoding (such as characters like ÁáÉéĚěÍíÓóÚúÝýŮůŘřŤťŠšĎČčŇň) is now supported in
--diff
mode (#324) indent
parameter is now taken into account byNormalizeTags
transformer (#323)spacecount
parameter is now taken into account in inline IFs by NormalizeSeparators transformer (#322)
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
NormalizeNewLines
transformer now removes empty lines inside multiline statements:
*** Keywords ***
Keyword
Keyword With
... Multiline arguments
... With empty lines
will be formatted to:
*** Keywords ***
Keyword
Keyword With
... Multiline arguments
... With empty lines
Fix for SplitTooLongLine
transformer breaking keywords with veeery long names (#314)
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 add 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
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
- Added
--skip-gitignore
flag to ignore.gitignore
files and parse files listed there (#299).
Tidied out and colorized the console output of the Robotidy such as help messages, transformer docstrings and errors (#298).
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 # robotidy: 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
- NormalizeNewLines now removes leading, trailing and consecutive empty lines in IF, FOR, WHILE, TRY EXCEPT blocks (#288)
- It's no longer possible to forcefully enable transformer not supported in installed Robot Framework version (#281, #283)
- 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:
It will disable all transformers that require Robot Framework greater than to run (even if you have Robot Framework greater than installed). (#253)
robotidy --target-version rf4 .
*** Tasks ***
will no longer be renamed to*** Test Cases ***
by NormalizeSectionHeaderName (#279).
-
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
- Add missing packaging dependency (#275)
- New
ReplaceReturns
transformer that replaces return statements (such as[Return]
setting orReturn From Keyword
keyword) withRETURN
statement (#231) - New
ReplaceBreakContinue
transformer that replacesContinue For Loop
andExit For Loop
keyword variants with CONTINUE and BREAK statements (#241) - New
InlineIf
transformer that replaces IF blocks with inline IF (#230) - Add
min_width
parameter toAlignSettingsSection
transformer. It allows to set minimal width of data column (#242) - Add
min_width
parameter toAlignVariablesSection
transformer. It allows to set minimal width of data column (#242) - Add
min_width
parameter toAlignTestCases
transformer. It allows to set minimal width of data column (#242) - Changed behaviour of
DiscardEmptySections
transformer. Now by default section with only comments are not considered empty. Configureallow_only_comments
toFalse
if you want to remove those sections (#235) - Add
skip_types
parameter toAlignVariablesSection
which allows to not align variables of particular type (#225) - Library names are now ignored by default by
RenameKeywords
transformer. Previously, it could result in an unexpected behaviour (#269). If you want to transform library names, passignore_library=False
to the transformer.
-
Change exceptions to be more user-friendly. Robotidy will try to recognize common mistakes. For unknown issues there is extra message with link to our bug board (#250)
-
Refactored Robotidy acceptance tests (#248)
-
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
- Unmodified files are now not saved to the disk (#237)
AddMissingEnd
transformer now properly handles IFs without indented block of code (#226)- Paths passed from command line are now checked against excluded paths (previously it was only checked when iterating over directories) (#227)
- Trailing whitespace is no longer added to blank lines in multiline statements when using align transformers (#219)
*** Tasks ***
is no longer converted to*** Test Cases ***
by NormalizeSectionHeaderName (#218)
-
New non default transformer
RenameTestCases
. It capitalizes first letter of the test case name, removes trailing dot and can replace provided regex pattern with substitute string (#183) -
New non default transformer
RenameKeywords
. It applies Title Case to keyword name and replace underscores by spaces and can replace provided regex pattern with substitute string (#183) -
Added
AlignTestCases
transformer for aligning templated test cases in column. Because it's in experimental mode it will be non default for now (see docs for information how to run it) (#185) -
Missing ENDs in for loop and if statements will be added by new
AddMissingEnd
transformer (#91) -
NormalizeAssignments
now recognizes assignments from*** Variables ***
section separately. It allows you to configure different assignment sign type for keyword calls and for variables section (#159)With this change following command will change all assignments signs to
=
for keyword calls and remove them in*** Variables ***
sections.robotidy -c NormalizeAssignments:equal_sign_type=equal_sign -c NormalizeAssignments:equal_sign_type_variables=remove <src>
-
New
OrderTags
(non default) transformer. It orders tags in lexicographic order (#205) -
New
NormalizeTags
(non default) transformer. It normalizes tag name case and removes duplicates (#212)
- It is now possible to provide source paths in configuration file (#154)
- Non default transformers can be enabled using
enabled=True
parameter (#182) - Semicolon in parameter value can now be escaped with
\:
(#190) - Default separator can be changed from space to tabular with new
--separator
option (#184) --lineseparator
option now acceptsauto
value for preserving line endings found in the file (#209)
- Robotidy will not print "Loaded configuration from ... " if the configuration is empty (#193)
- no source path provided error now exits with code 1 instead of 0 (#208)
- ReplaceRunKeywordIf now removes ELSE branch if it is unnecessary (#192)
- Robotidy will now not crash on directory path #177
- Ignore paths from .gitignore and
--exclude
option, allow to ignore paths through using--extend-exclude
#110 - Add extra indent for arguments in Suite Setup/Teardown, Test Setup/Teardown in AlignSettingsSection #155
- OrderSettingsSection will now preserve order of imports. It can be configured to work as before and other settings order can be also preserved #167
- When ordering imports with OrderSettingsSection, Remote library will not be grouped with other standard libs #175
- Allow to disable selected transformers #170
- Do not count documentation length when aligning all columns in settings section #156
- Acknowledge
--lineseparator
option #163 - Do not print empty line for file without changes with
--diff
option #160
- Allow to use spaces in pyproject.toml configuration file #148
- Invalid option names in pyproject.toml file will now stop Robotidy (with optional hint message) #150
- Fixed spelling issues in source code and docs #146
AssignmentNormalizer
was renamed toNormalizeAssignment
for consistent naming with other transformers #115- It is now possible to select what sections are normalized in
NormalizeSeparators
transformer withsections
param #116 OrderSettings
now puts settings before comments and empty lines at the end of keyword/test case body #118, #125
- New option
--output
option for saving transformed file to provided path instead of overwriting source file #108 --desc
now acceptsall
for printing out description of all transformers #105- Robotidy will now suggest similar names for invalid transformer names used with
--transform
or--desc
options #107 --list
now prints transformers in alphabetical order #141
- Renamed short version of
--lineseparator
to-ls
to avoid collision with--list\-l
- Description for disabled transformers can be now displayed & disabled transformers are in
--list
output #114 - Robotidy should now correctly load configuration files from path when using
--config
#138 - ReplaceRunKeywordIf will now set variable values to
None
if there is no ELSE branch #140 - Transformers should always use the same order. If you need to use custom order, provide --force-order flag #142
- Removed
'--describe-transformer
and--list-transformers
aliases for--list
and--desc
- Added
-h
alias for--help
command - Warn user instead of doing nothing when invoking robotidy without any arguments #106
- AlignVariablesSection now supports
--startline
and--endline
options for aligning only part of*** Variables ***
section #62 - AlignVariablesSection now supports
up_to_column
parameter so it is possible to chose how much column are width aligned - AlignVariablesSection and AlignSettingsSection change
up_to_column
default value from 0 (meaning all columns) to 2 (only first two columns are width aligned, rest use fixed length) # - New AlignSettingsSection for aligning
*** Settings ***
section into columns #60 - New NormalizeSeparators for normalizing all separators and indents to fixed length (according to global
--spacecount
option) #32 - New RemoveEmptySettings transformer for removing empty settings such like
Suite Setup
or[Arguments]
. Settings that are overwriting suite settings (like empty[Tags]
overwritingDefault Tags
) are preserved. See the docs for config options #78 - New SmartSortKeywords transformer (disabled by default) for sorting out keywords inside
*** Keywords ***
section #52 - New MergeAndOrderSections transformer for merging duplicated sections and ordering them (order is configurable) #70
- New OrderSettings transformer for ordering settings like [Arguments], [Setup], [Return] inside Keywords and Test Cases #59
- New OrderSettingsSection transformer for ordering settings, imports inside
*** Settings ****
section #100
- New option
--configure
or-c
for configuring transformer parameters. It works the same way configuring through--transform
works. The benefit of using--configure
is that you can configure selected transformers and still run all transformers #96 - Transformers can now be disabled by default if you add
ENABLED = False
class attribute to your class. Those transformers will be only run when selected explicitly with--transform
option #10 - Support for
pyproject.toml
configuration files. Because of the required changes there are backward incompatible changes done torobotidy.toml
syntax. See example from README #66 --list-transformers
output is now ordered. Also transformers themselves will always run in the same predefined order #69--describe-transformer
output is now pre-formatted (removed rst formatting) #83- Several options have now abbreviations: #92
--transform
can be also used with-t
--list-transformers
can be also used with--list
or-l
--describe-transformer
can be also used with--desc
or-d
- SplitTooLongLine will now parse multiple assignment values correctly #68
- AlignSettingsSection is now parsing empty lines in multi lines correctly (those lines are removed) #75
- Fix
--diff
option not displaying colours on Windows #86 - Fix issue where variable was not left aligned if name was prefixed with space (
{variable} 4
) #88
- Support for pipes is now removed. All pipes will be converted to spaces by NormalizeSeparators transformer. It can be restored if people that use pipe syntax request for it
- Files with invalid encoding will now not stop robotidy execution - warning will be printed instead
- AlignVariablesSection should ignore lines with only comments
- Added alignVariablesSection for aligning variables and their values in column like appearance #50
- Robotidy should not add new (extra) line at the end of file #47
- BuiltIn.Run Keyword If should now work with ReplaceRunKeywordIf transformer #53
- DiscardEmptySections - empty sections are removed
- SplitTooLongLine - keywords with too long lines are split
- NormalizeSettingName - ensure that setting names are Title Case - Test Template, Library
- AssignmentNormalizer - use only one type of assignment
- NormalizeNewLines - ensure proper number of empty lines between keywords, test cases and sections
- NormalizeSectionHeaderName - ensure that sections are in
*** Section ***
or*** SECTION ***
format - ReplaceRunKeywordIf - replace RunKeywordIf with IF blocks
- configurable transformers
- selectable transformers (chose how you want to transform your code)
- robotidy configuration can be supplied from cli and config file (which can be pointed to or autodetected in directory if the name is 'robotidy.toml'
- option
--no-overview
to disable writing to files - option
--diff
to display file diff with the changes done by robotidy - option
--check
to return status depending on if any file was modified by robotidy - options
--spacecount
and--lineseparator
for defining global formatting rules --startline
and--endline
arguments for narrowing down what robotidy is supposed to transform in file--list-transformers
and--describe-transformer
for displaying information about existing transformers