Skip to content

Commit 4513358

Browse files
authored
Prepare release (#214)
* blackify * improve docs * update version * run black
1 parent 9d44048 commit 4513358

36 files changed

+689
-662
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
```
1414
robotidy -c NormalizeAssignments:equal_sign_type=equal_sign -c NormalizeAssignments:equal_sign_type_variables=remove <src>
1515
```
16+
- New `OrderTags` (non default) transformer. It orders tags in lexicographic order ([#205](https://github.com/MarketSquare/robotframework-tidy/issues/205))
17+
- New `NormalizeTags` (non default) transformer. It normalizes tag name case and removes duplicates ([#212](https://github.com/MarketSquare/robotframework-tidy/issues/212))
1618

1719
### Features
1820
- It is now possible to provide source paths in configuration file ([#154](https://github.com/MarketSquare/robotframework-tidy/issues/154))

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Installation <a name="installation"></a>
3737

3838
You can install Robotidy simply by running:
3939
```
40-
pip install robotframework-tidy
40+
pip install -U robotframework-tidy
4141
```
4242

4343
Usage <a name="usage"></a>
@@ -56,6 +56,9 @@ All command line options can be displayed in help message by executing:
5656
robotidy --help
5757
```
5858

59+
See [documentation](https://robotidy.readthedocs.io/en/latest/configuration/index.html) for information how to configure
60+
robotidy.
61+
5962
Example <a name="example"></a>
6063
-------
6164
Ugly code before transforming with robotidy:

docs/source/transformers/NormalizeTags.rst

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

33
NormalizeTags
44
================================
5+
Normalize tag names by normalizing case and removing duplicates.
56

67
NormalizeTags is not included in default transformers, that's why you need to call it with ``--transform`` explicitly::
78

@@ -12,13 +13,13 @@ Or configure `enable` parameter::
1213
robotidy --configure NormalizeTags:enabled=True
1314

1415

15-
Supported cases: lowercase (default), uppercase, titlecase.
16+
Supported cases: lowercase (default), uppercase, title case.
1617
You can configure case using `case` parameter::
1718

1819
robotidy --transform NormalizeTags:case=uppercase
1920

2021

21-
You can remove duplicates without normalizing case by setting normalize_case parameter to False::
22+
You can remove duplicates without normalizing case by setting `normalize_case` parameter to False::
2223

2324
robotidy --transform NormalizeTags:normalize_case=False
2425

docs/source/transformers/OrderTags.rst

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

33
OrderTags
44
================================
5+
Order tags in case-insensitive way in ascending order.
56

67
OrderTags is not included in default transformers, that's why you need to call it with ``--transform`` explicitly::
78

@@ -11,10 +12,8 @@ Or configure `enable` parameter::
1112

1213
robotidy --configure OrderTags:enabled=True
1314

14-
By default tags are ordered in case-insensitive way in ascending order.
1515
This relates to tags in Test Cases, Keywords, Force Tags and Default Tags.
1616

17-
1817
.. tabs::
1918

2019
.. code-tab:: robotframework Before
@@ -51,7 +50,7 @@ This relates to tags in Test Cases, Keywords, Force Tags and Default Tags.
5150
[Tags] aa Ab ba Bb Ca Cb
5251
No Operation
5352

54-
Using the same example with reverse=True param we will get tags in descending order::
53+
Using the same example with `reverse=True` param we will get tags in descending order::
5554

5655
robotidy --transform OrderTags:reverse=True src
5756

@@ -121,4 +120,4 @@ Force Tags and Default Tags ordering can be disabled like this::
121120
*** Test Cases ***
122121
Tags Upper Lower
123122
[Tags] aa Ab ba Bb Ca Cb
124-
My Keyword
123+
My Keyword

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tool.black]
2+
line-length = 120

robotidy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from robotidy.version import __version__
22

33

4-
__all__ = ['__version__']
4+
__all__ = ["__version__"]

robotidy/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from robotidy.cli import cli
22

33

4-
if __name__ == '__main__':
4+
if __name__ == "__main__":
55
cli()

robotidy/api.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@
1212
class RobotidyAPI(Robotidy):
1313
def __init__(self, src: str, output: Optional[str], **kwargs):
1414
config = find_and_read_config((src,))
15-
config = {
16-
k: str(v) if not isinstance(v, (list, dict)) else v
17-
for k, v in config.items()
18-
}
15+
config = {k: str(v) if not isinstance(v, (list, dict)) else v for k, v in config.items()}
1916
converter = TransformType()
20-
transformers = [converter.convert(tr, None, None) for tr in config.get('transform', ())]
21-
configurations = [converter.convert(c, None, None) for c in config.get('configure', ())]
17+
transformers = [converter.convert(tr, None, None) for tr in config.get("transform", ())]
18+
configurations = [converter.convert(c, None, None) for c in config.get("configure", ())]
2219
formatting_config = GlobalFormattingConfig(
23-
space_count=kwargs.get('spacecount', None) or int(config.get('spacecount', 4)),
24-
separator=kwargs.get('separator', None) or config.get('separator', 'space'),
25-
line_sep=config.get('lineseparator', 'native'),
26-
start_line=kwargs.get('startline', None) or int(config['startline']) if 'startline' in config else None,
27-
end_line=kwargs.get('endline', None) or int(config['endline']) if 'endline' in config else None
20+
space_count=kwargs.get("spacecount", None) or int(config.get("spacecount", 4)),
21+
separator=kwargs.get("separator", None) or config.get("separator", "space"),
22+
line_sep=config.get("lineseparator", "native"),
23+
start_line=kwargs.get("startline", None) or int(config["startline"]) if "startline" in config else None,
24+
end_line=kwargs.get("endline", None) or int(config["endline"]) if "endline" in config else None,
2825
)
29-
exclude = config.get('exclude', None)
30-
extend_exclude = config.get('extend_exclude', None)
26+
exclude = config.get("exclude", None)
27+
extend_exclude = config.get("extend_exclude", None)
3128
exclude = validate_regex(exclude if exclude is not None else DEFAULT_EXCLUDES)
3229
extend_exclude = validate_regex(extend_exclude)
3330
super().__init__(
@@ -42,7 +39,7 @@ def __init__(self, src: str, output: Optional[str], **kwargs):
4239
verbose=False,
4340
check=False,
4441
output=output,
45-
force_order=False
42+
force_order=False,
4643
)
4744

4845

robotidy/app.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,26 @@
1414
StatementLinesCollector,
1515
decorate_diff_with_color,
1616
GlobalFormattingConfig,
17-
ModelWriter
17+
ModelWriter,
1818
)
1919

2020

2121
class Robotidy:
22-
def __init__(self,
23-
transformers: List[Tuple[str, List]],
24-
transformers_config: List[Tuple[str, List]],
25-
src: Tuple[str, ...],
26-
exclude: Pattern,
27-
extend_exclude: Pattern,
28-
overwrite: bool,
29-
show_diff: bool,
30-
formatting_config: GlobalFormattingConfig,
31-
verbose: bool,
32-
check: bool,
33-
output: Optional[Path],
34-
force_order: bool
35-
):
22+
def __init__(
23+
self,
24+
transformers: List[Tuple[str, List]],
25+
transformers_config: List[Tuple[str, List]],
26+
src: Tuple[str, ...],
27+
exclude: Pattern,
28+
extend_exclude: Pattern,
29+
overwrite: bool,
30+
show_diff: bool,
31+
formatting_config: GlobalFormattingConfig,
32+
verbose: bool,
33+
check: bool,
34+
output: Optional[Path],
35+
force_order: bool,
36+
):
3637
self.sources = get_paths(src, exclude, extend_exclude)
3738
self.overwrite = overwrite
3839
self.show_diff = show_diff
@@ -44,20 +45,20 @@ def __init__(self,
4445
self.transformers = load_transformers(transformers, transformers_config, force_order=force_order)
4546
for transformer in self.transformers:
4647
# inject global settings TODO: handle it better
47-
setattr(transformer, 'formatting_config', self.formatting_config)
48+
setattr(transformer, "formatting_config", self.formatting_config)
4849

4950
def transform_files(self):
5051
changed_files = 0
5152
for source in self.sources:
5253
try:
5354
stdin = False
54-
if str(source) == '-':
55+
if str(source) == "-":
5556
stdin = True
5657
if self.verbose:
57-
click.echo('Loading file from stdin')
58+
click.echo("Loading file from stdin")
5859
source = self.load_from_stdin()
5960
elif self.verbose:
60-
click.echo(f'Transforming {source} file')
61+
click.echo(f"Transforming {source} file")
6162
model = get_model(source)
6263
diff, old_model, new_model = self.transform(model)
6364
if diff:
@@ -97,16 +98,21 @@ def save_model(self, model):
9798
output = self.output or model.source
9899
ModelWriter(output=output, newline=self.formatting_config.line_sep).write(model)
99100

100-
def output_diff(self, path: str, old_model: StatementLinesCollector, new_model: StatementLinesCollector):
101+
def output_diff(
102+
self,
103+
path: str,
104+
old_model: StatementLinesCollector,
105+
new_model: StatementLinesCollector,
106+
):
101107
if not self.show_diff:
102108
return
103-
old = [l + '\n' for l in old_model.text.splitlines()]
104-
new = [l + '\n' for l in new_model.text.splitlines()]
105-
lines = list(unified_diff(old, new, fromfile=f'{path}\tbefore', tofile=f'{path}\tafter'))
109+
old = [l + "\n" for l in old_model.text.splitlines()]
110+
new = [l + "\n" for l in new_model.text.splitlines()]
111+
lines = list(unified_diff(old, new, fromfile=f"{path}\tbefore", tofile=f"{path}\tafter"))
106112
if not lines:
107113
return
108114
colorized_output = decorate_diff_with_color(lines)
109-
click.echo(colorized_output.encode('ascii', 'ignore').decode('ascii'), color=True)
115+
click.echo(colorized_output.encode("ascii", "ignore").decode("ascii"), color=True)
110116

111117
@staticmethod
112118
def convert_configure(configure: List[Tuple[str, List]]) -> Dict[str, List]:

0 commit comments

Comments
 (0)