Skip to content

Configuration file support #5337

Open

Description

@pekkaklarck

Robot Framework should get support for configuration files. Configuration files should be loaded automatically (unless disabled) and allow specifying same settings that can be given from the command line. This would make it possible to, for example, to automatically enable the RPA mode, specify listeners that should always be used, and so on. This would be especially useful with features that require more complex configuration such as custom settings (#4409).

The main reason Robot currently doesn't support configuration files is that it has its own argument file concept that has many of the same benefits. Argument files aren't loaded automatically, though, and them being a Robot-only solution means that you cannot have all project configuration in one place.

Although the basic idea is clear, there are lot of design decisions to be made:

  1. What format? Python has pretty much standardized to TOML as configuration syntax and I rather strongly believe we should use that too. tomllib is only available starting from Python 3.11, but we can require people using older Python versions to install a backport if they want to use config files.
  2. Should we support the standard pyproject.toml or a custom robot.toml? I believe we should support both. Actual settings should also be exactly the same regardless the file, but the top level table structure is naturally different.
  3. Where should we look for configuration files? My understanding is that pyproject.toml should be only looked from the current directory, but with our robot.toml it would probably make sense to support system wide, user wide, project wide, and custom configuration so that the latter ones have precedence over earlier ones. System wide and user wide configs would be loaded from an OS specific configuration file locations, project wide configuration from the current directory, and custom configs could be given using a command like option like --config path/to/custom.toml. There should also be a way to disable loading configuration files automatically.
  4. How should each command line option be supported in a configuration file? It's probably best to return to this when implementation starts. This is an important topic, because making changes later causes backwards compatibility problems.

Activity

  1. added this to the v7.3 milestone on Feb 11, 2025
  2. rinatagishev commented on Feb 13, 2025

    @rinatagishev

    What is this configuration for?
    tests filtering?
    variables setting or referencing variables file?
    binding other configs, including configs based on existing variables?

  3. LucianCrainic commented on Mar 8, 2025

    @LucianCrainic
    Contributor

    Hello @pekkaklarck any updates on this ? Will there be a toml / yaml file for configuration settings ? What purpose will it serve ?

  4. pekkaklarck commented on Mar 27, 2025

    @pekkaklarck
    MemberAuthor

    I finally updated the description so hopefully it now answers your questions @rinatagishev and @LucianCrainic.

    While updating the description I realized now many design decisions there are to be made and how much getting all this implemented does. In addition to the support for finding and loading configuration files, we need to integrate it with the current code for parsing command line options and handling settings internally. Unfortunately most of the current code is pretty bad, and I believe we should rewrite it as part of this project. That allows us to design this properly, but it also increases the development effort.

    My current thinking is that this is so big task that it's better to move it to RF 8.0 scope. Doing this in a major release would also help a little if we needed to make some backwards incompatible changes. If you feel that this should be implemented earlier, please comment this issue. In that case you need to be prepared to help with the design and implementation work, though.

  5. Noordsestern commented on Mar 27, 2025

    @Noordsestern
    Member

    Not sure if you are aware:

    Robotcode introduced robot.toml more than a year ago and the configs are pretty well used. It even supports execution profiles and IDE integration of the configs: https://robotcode.io/01_about/#configure-your-robot-framework-environment-with-robot-toml

    Maybe, the efforts could be less when adopting the approach of Robotcode. That would save design and implementation efforts.

    Until then, users can already use configuration files by utilizing Robotcode.

  6. modified the milestones: v7.3, v8.0 on Apr 4, 2025
  7. jyligehc commented on Apr 7, 2025

    @jyligehc

    Hi Pekka,
    This feature sounds a good idea.

    Your point 3 sounds good and, in fact, it pretty much follows what is being done in invoke (tool also being used in Robot development process).

    https://docs.pyinvoke.org/en/stable/concepts/configuration.html#config-hierarchy
    Points 3-7 in the documentation.

    In point 5 the configuration could come from pyproject.toml if robot.toml is not found.
    It could try to search these from the current directory and its parent directories.

    I also think that while configuration is being processed it would be quite easy to handle environment variables and including them as one source of configuration as well.

  8. bhirsz commented on Aug 20, 2026

    @bhirsz
    Contributor

    As already mentioned, some tools in robot ecosystem already use toml files (I adopted robot.toml as well, after robotcode). Configuration file support is something I rewrote completely few times until I reached satysfying point. And it looks like current robocop design could be reused for robot itself (how we manage config Discovery, schemat, building from multiple sources etc). I agree with all previous statements from initial post, but I have some new questions:

  9. bhirsz commented on Aug 27, 2026

    @bhirsz
    Contributor

    I will attempt implementing it. I had short discussion with Pekka on the slack regarding this, we have decided it may be good idea to develop it as external module: the reason is that several tools and libraries may need similiar capability and we can easily vendor-in it in the robotframework itself (so it will be developed separetely for now, so we can start working on it already, and later we will copy it to robot).

    We have some basic requirements for now:

    • no external libraries if unnecessary - so we're limited to argparse, optparse or getopt (with focus rather on the two latter ones, since we will implement part of the parsing)
    • following above requirement, we want to use builtin tomllib library
    • the tool will allow us to construct the cli/config parser. It will take default value, override it with config file, then env variable, then cli value, and return parsed object
    • it will support both pyproject.toml (required section [tools.robot]) and robot.toml (with optional section). we will discuss later whether we want to have robotframewort.toml (and/instead)
    • we will search for config file in the root (either cwd or 'find the root' like we do in robocp or other tools, so going up until we find it or find .git directory), then user directories / common tool directory according to commonly used approaches by other tools

    I will open separate repositorium and keep ideas / technical decisions here, and get back to this issue once we have clarified approach.

  10. pekkaklarck commented on Aug 28, 2026

    @pekkaklarck
    MemberAuthor

    Quick comments to what @bhirsz wrote above:

    1. Implementing this in a separate project is definitely a good idea for various reasons:

      • Also other tools in the Robot Framework ecosystem and also outside it will benefit from a convenient way to parse command line options, config files and environment variables. When this is an external project, it cab be published in PyPI separately from Robot.
      • This functionality is targeted for RF 8.0 and it's unclear when its development starts. Development of this functionality can start In a separate project already now.
      • In an external project it's possible to have more strict typing and linting requirements than in Robot Framework core where we have a lot of untyped legacy code.
    2. I like how with Robot you can nowadays define options by writing a --help text and our argument parser then parsing all information from there. Enhancing it to support default values, list of accepted values, type information, and so on is likely not possible, so we need to come up with something new. Whatever we come up with should be convenient to use and be based on conventions rather than heavy configuration.

    3. RF 8.0 will be out after Python 3.10 has reached its EOL. tomllib is new in Python 3.11 and we can either make that the minimum version or require Python 3.10 users to install the external tomllib module. Either way, we don't need to care about tomllib not being available.

  11. pekkaklarck commented on Aug 28, 2026

    @pekkaklarck
    MemberAuthor

    We did some very initial design discussion and I proposed this kind of approach:

    class RobotConfig(SomeBaseClassHere):
        """This is shown as the general part of the help text."""
        version = "8.0"    # Could also use a decorator with these.
    
        @option(short="N")
        def name(self, name: str | None = None):
            """Documentation of the `--name` option.
    
            Writing multiline docs is pretty convenient!
            """
    
        @option(short="W"):
        def console_width(self, chars: int = 78):
            """Doc here."""
    
        @option
        def listener(self, *listeners):
            """Doc here."""
    
    
    config = ConfigProcessor(RobotConfig).process()
    print(config.options, config.arguments)

    The above would automatically parse command line options --name (-N), --console-width (-W) and --listener, and search name, console_width and listeners from the config files. It would also figure out default values, types (and do automatic conversion), whether an option is allowed once or multiple times, and so on.

    Incidentally RoboCop uses something similar, so it seems we have the base design done. Let's continue the design discussion in the new project @bhirsz will set up.

  12. bhirsz commented on Aug 28, 2026

    @bhirsz
    Contributor

    Robocop uses different approach - we use typer for cli parsing. However we reuse similiar approach in different parts of the tool, and we also use 'class-based' approach for config parsing etc.

    I've created https://github.com/MarketSquare/confargs repository. I've also implemented the MVP of tool.

    The equivalent of robot framework parser lies here: https://github.com/MarketSquare/confargs/blob/main/tests/robot_cli.py

    Now I will focus on code review (it was mostly generated, based on my requirements) and adding some acceptance tests to see what we are still missing. Also some features are still not implemented.

  13. bhirsz commented on Sep 18, 2026

    @bhirsz
    Contributor

    I had questions regarding robotcode <> robot configuration file syntax portability. The aim it so have as closest syntax as possible, but most likely there will be breaking changes between the two. For example if robotcode keeps robtcode specific parameter names inside tool.robot section - if we use strict mode on default, it will report unknown parameter.

    Additional differences:

    • robotcode use plurar parameter names (variable-files, variables..). It's up to discussion - prefferably we shoud support cli names always, as it's less confusing. But variable = <array> may be also confusing
    • speaking of variables, robotcode support dict type (so not variables = ["ENV:dev"] but variables = {"ENV": "dev"} or [variables] subsection in toml) which looks nice

    There are some pros of robotcode approach, but I must admit I had to consult the documentation first when I simply tried to use robot cli parameter names in toml in the past. We could support both (singular/plurar names for list-like options, and support list/dict for variables).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions