Skip to content

Commit d74c55b

Browse files
authored
Allow spaces in pyproject.toml config file (#149)
* allow spaces in toml config file * update docs
1 parent 8ca3612 commit d74c55b

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Features
6+
- Allow to use spaces in pyproject.toml configuration file [#148](https://github.com/MarketSquare/robotframework-tidy/issues/148)
7+
58
## 1.3.0
69

710
### Transformers

docs/source/configuration/config_file.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Flag-like options like ``--diff``, ``--overwrite/no-overwrite``, ``--check`` req
2121
``--transform`` and ``--configure`` require defining list of strings.
2222

2323
See example:
24+
2425
.. code-block:: toml
2526
2627
[tool.robotidy]
@@ -34,4 +35,25 @@ See example:
3435
]
3536
configure = [
3637
"SplitTooLongLine:split_on_every_arg=False"
37-
]
38+
]
39+
40+
Transformers with multiple parameters can be configured in one line (each param delimited by `:`) or in multi lines:
41+
42+
.. code-block:: toml
43+
44+
[tool.robotidy]
45+
configure = [
46+
"OrderSettings:keyword_before=documentation,tags,timeout,arguments:keyword_after=return"
47+
"OrderSettingsSection:group_order=documentation,imports,settings,tags",
48+
"OrderSettingsSection:imports_order=library,resource,variables"
49+
]
50+
51+
Transformer configuration can contain spaces for better readability:
52+
53+
.. code-block:: toml
54+
55+
[tool.robotidy]
56+
configure = [
57+
"OrderSettingsSection: group_order = documentation,imports,settings,tags",
58+
"OrderSettingsSection: imports_order = library, resource, variables"
59+
]

robotidy/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class TransformType(click.ParamType):
7373
def convert(self, value, param, ctx):
7474
name = ''
7575
try:
76-
name, args = split_args_from_name_or_path(value)
76+
name, args = split_args_from_name_or_path(value.replace(' ', ''))
7777
except ValueError:
7878
exc = f'Invalid {name} transformer configuration. ' \
7979
f'Parameters should be provided in format name=value, delimited by :'

robotidy/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def find_similar(self, name, candidates):
162162
if not matches:
163163
return ''
164164
matches = self.get_original_candidates(matches, norm_cand)
165+
if len(matches) == 1 and matches[0] == name:
166+
return ''
165167
suggestion = ' Did you mean:\n'
166168
suggestion += '\n'.join(f' {match}' for match in matches)
167169
return suggestion

tests/utest/test_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ def test_read_pyproject_config(self):
116116
'SplitTooLongLine'
117117
],
118118
'configure': [
119-
'DiscardEmptySections:allow_only_comments=False'
119+
'DiscardEmptySections:allow_only_comments=False',
120+
'OrderSettings: keyword_before = documentation,tags,timeout,arguments'
120121
]
121122
}
122123
config_path = str(Path(Path(__file__).parent, 'testdata', 'only_pyproject', 'pyproject.toml'))
@@ -134,7 +135,8 @@ def test_read_pyproject_config_e2e(self):
134135
'SplitTooLongLine'
135136
],
136137
'configure': [
137-
'DiscardEmptySections:allow_only_comments=False'
138+
'DiscardEmptySections:allow_only_comments=False',
139+
'OrderSettings: keyword_before = documentation,tags,timeout,arguments'
138140
]
139141
}
140142
config_path = str(Path(Path(__file__).parent, 'testdata', 'only_pyproject'))

tests/utest/testdata/only_pyproject/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ transform = [
88
"SplitTooLongLine"
99
]
1010
configure = [
11-
"DiscardEmptySections:allow_only_comments=False"
11+
"DiscardEmptySections:allow_only_comments=False",
12+
"OrderSettings: keyword_before = documentation,tags,timeout,arguments"
1213
]

0 commit comments

Comments
 (0)