Skip to main content

Code autoformatter for Robot Framework

Project description

GitHub Workflow Unit Tests Status Code coverage on master branch PyPI - License

Robotidy

Introduction

Robotidy is spiritual descendant of Robot Framework’s robot.tidy package. Its main purpose is to format Robot Framework code according to agreed code standards. You can run Robotidy without configuring anything but you can also change how it behaves through CLI or configuration file.

Requirements

Python 3.7+ and Robot Framework 4.0.0+.

Installation

You can install Robotidy by running:

pip install git+git://github.com/MarketSquare/robotframework-tidy

Usage

When called without any arguments, robotidy will not do anything. It requires at least one argument: source to file/directory with robot files:

robotidy tests
robotidy test.robot
robotidy tests/resources  test.robot

Executing selected transformers

You can run robotidy with selected transformers. Use --transform argument for this:

robotidy --transform ReplaceRunKeywordIf src

Some transformers provide configurable parameters. You can modify them by adding : after transformer name:

robotidy --transform DiscardEmptySections:allow_only_comments=True src

It is possible to develop your own transformers. You can use module name (if it is installed in your env) or path to file with class:

robotidy --transform MyTransformers.YourCustomTransformer --transform C:\transformers\YourCustomTransformer2.py src

Command line options

You can list available options by running robotidy --help:

Usage: robotidy [OPTIONS] [PATH(S)]

Options:
  --transform TRANSFORMER_NAME    Transform files from [PATH(S)] with given
                                  transformer

  --overwrite / --no-overwrite    Overwrite source files.
  --diff                          Output diff of each processed file.
  -s, --spacecount INTEGER        The number of spaces between cells in the
                                  plain text format. Default is 4.

  -l, --lineseparator [native|windows|unix]
                                  Line separator to use in outputs. The
                                  default is 'native'.
                                  native:  use operating system's native line separators
                                  windows: use Windows line separators (CRLF)
                                  unix:    use Unix line separators (LF)

  -p, --usepipes                  Use pipe ('|') as a column separator in the
                                  plain text format.

  -sl, --startline INTEGER        Limit robotidy only to selected area. If
                                  --endline is not provided, format text only
                                  at --startline. Line numbers start from 1.

  -el, --endline INTEGER          Limit robotidy only to selected area. Line
                                  numbers start from 1.

  -v, --verbose
  --config FILE                   Read configuration from FILE path.
  --list-transformers             List available transformers and exit.
  --describe-transformer TRANSFORMER_NAME
                                  Show documentation for selected transformer.
  --version                       Show the version and exit.
  --help                          Show this message and exit.

Configuration file

Robotidy can read configuration from files with toml type. Options are loaded in following order:
  • auto-discovered configuration file (robotidy.toml)

  • configuration file passed with --config

  • command line arguments

By default if --config argument is not used, robotidy look for configuration file named robotidy.toml in common directories for passed sources and execution directory.

It is possible to mix configuration between config file and command line, but if the same parameters are used command line parameter value will be used instead (reference to loading order). It’s important because you cannot specify some of the transformers in config file and come in CLI - you need to list all required transformers in one place.

Example configuration file:

[main]
overwrite = false
diff = false
spacecount = 4

[transformers]
    [transformers.DiscardEmptySections]
        allow_only_comments = true
    [transformers.ReplaceRunKeywordIf]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework-tidy-1.0.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

robotframework_tidy-1.0.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file robotframework-tidy-1.0.0.tar.gz.

File metadata

  • Download URL: robotframework-tidy-1.0.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for robotframework-tidy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 23650466a61e8d843878d3862cdd8ef428991f7ee697038b80c50b266c8526ff
MD5 e051704657c07c1956d1a628d3684b1d
BLAKE2b-256 32d3d408fea9d69c64d59fb8656b1162472beeaba7ab3ecd5fff2bfcea25ab68

See more details on using hashes here.

Provenance

File details

Details for the file robotframework_tidy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: robotframework_tidy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for robotframework_tidy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 271af2dab0f1706f5cdf2ff27c4774bff4284787e4c84ed43b6534078cc9f9fb
MD5 204e5085122e210cb5060d1ed1471449
BLAKE2b-256 372274aba06fa1b550268c73fc1b590c5c55e8a249075f242a22c54877c3818e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page