Config of robotidy

200 views
Skip to first unread message

Geist Eng

unread,
Jul 29, 2022, 11:38:02 AM7/29/22
to robotframework-users
I have read the docs on the robotidy config format a number of times and have a number of questions.
  1. It is still not clear how to do what I would consider the basic config of disabling a default enabled Transformer.
    1. e.g. all of the Replace* transformers
    2. Surprised those are on my default as that make large changes in one's code base.  A change like that has to be managed, including testing
  2. It is not clear the format of any config file is the same format of pyproject.toml
    1. The docs ONLY show examples for what seems like pyproject.toml
    2. Like is the [tool.robottidy] section header required for all config files?  toml format does not require that and it seems this is needed for pyproject.toml due to that config covers a lot of tool's config
  3. What is up with the _=_ in the config examples in the docs?
    1. This is not required by toml at all
In the past I used robot.tidy only to generate docs as our .robot format uses the pipe separator and slightly different format for readability that Tidy would produce. 

With this new robotidy I think it could be used for a real code beautifier on actual code, but it seems the docs need work.

I wish I would have noticed robot.tidy was being depracted but we went from v3 thru v4 to v5 very quickly since v5 was out by the time we needed to update our implementation.

Geist Eng

unread,
Jul 29, 2022, 4:28:29 PM7/29/22
to robotframework-users
From testing I have found:
  1. a config file used with --config MUST have the Table name [tool.robotidy]
    1. this should be clearer in the docs as it now comes in the context of pyproject.toml
  2. the _=_ was from a browser plugin, so that is a non-issue
  3. found the example I missed on how to disable a Transformer:
    1. robotidy --configure TRANSFORMER_NAME:enabled=False src
    2. But for the ReplaceRunKeywordIf it fails both as used on the command line and in a config file.
      1. So yet found a way to disable the Replace* transformer
      2. Going to try the force-order next
robotidy --configure ReplaceRunKeywordIf:enable=False src.robot

Error: ReplaceRunKeywordIf: Failed to import. Verify if correct name or configuration was provided. This transformer does not accept arguments but they were provided.

Geist Eng

unread,
Jul 30, 2022, 12:01:06 AM7/30/22
to robotframework-users
Update:  it is possible to disable any of the default Replace Transformers.

The error msg I got mislead me: This transformer does not accept arguments but they were provided.

It does take the enabled argument, but NOT the enable.  Note the missing 'd' on my example in previous post  :-)

For completeness the Robotidy config that will disable the Replace* transformers:

[tool.robotidy]
configure = [
    ReplaceRunKeywordIf:enabled=False
    ReplaceBreakContinue:enabled=False
    ReplaceReturns:enabled=False
]

I have no other open issues/question on this thread.


Geist Eng

unread,
Jul 30, 2022, 12:27:09 PM7/30/22
to robotframework-users
Ugh.  Forgot the commas and quotes for the list.  Corrected example

[tool.robotidy]
configure = [
    "ReplaceRunKeywordIf:enabled=False",
    "ReplaceBreakContinue:enabled=False",
    "ReplaceReturns:enabled=False"
]

Bartłomiej Hirsz

unread,
Aug 1, 2022, 5:01:31 AM8/1/22
to robotframework-users
Robotidy uses pyproject.toml file (which then is toml file). We're using the same approach as many Python tools are using - for example having tool.name_of_tool section in the configuration file. It's described in https://robotidy.readthedocs.io/en/stable/configuration/config_file.html . If there is something missing or unclear please point it out, I always regard the documentation as most important part of the project and I would love to improve it :)

Like you noticed, you can disable default transformers using "enabled" parameter. It's described on this page https://robotidy.readthedocs.io/en/stable/configuration/configuring_transformers.html#configuring-transformers . Hovewer I agree that docs could be improved a bit - for example we include information about "enabled" parameter in every non-default transformer (like https://robotidy.readthedocs.io/en/stable/transformers/IndentNestedKeywords.html ) and we could do the same for default ones. 

Your discovered bug with your typo :) - in most cases I try to have user friendly exceptions and print information if there is another parameter with similar name. For example:
robotidy_error.png

It should also provide such information for you but there is some issue - I will investigate (https://github.com/MarketSquare/robotframework-tidy/issues/368). 

3. "What is up with the _=_ in the config examples". Now I also see this in my browser, I will think about changes in our docs theme so it's not displayed that way.
Reply all
Reply to author
Forward
0 new messages