Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: generic configuration manipulation from the command line #634

Closed
obestwalter opened this issue Sep 15, 2017 · 10 comments
Closed

RFC: generic configuration manipulation from the command line #634

obestwalter opened this issue Sep 15, 2017 · 10 comments
Labels
area:configuration feature:new something does not exist yet, but should help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. level:hard rought estimate that this might be quite hard to implement needs:discussion It's not quite clear if and how this should be done
Milestone

Comments

@obestwalter
Copy link
Member

obestwalter commented Sep 15, 2017

This came up in #631.

Maybe tox should just have an -o option to override any ini option, like pytest has? With that, you could do tox -o skip_missing_interpreters=false but also e.g. tox -o distdir=foo, and maybe even tox -o '[testenv:py35]basepython=python3.5'.

-- @The-Compiler

pytest --help:

-o [OVERRIDE_INI [OVERRIDE_INI ...]], 
--override-ini=[OVERRIDE_INI [OVERRIDE_INI ...]]

        override config option with option=value style, e.g. `-o xfail_strict=True`.

I think this would be a great direction and would render all needs for specific command line overrides obsolete.

Further interesting snippets from that discussion:

Ooh that sounds like the best option.

If we wanted to make it generic perhaps something like this?

  • -o tox.skip_missing_interpreters=True
  • --option testenv:py35.basepython=python3.5

Or with brackets?

  • -o [tox]skip_missing_interpreters=True
  • -o [testenv:py35]basepython=True

-- @asottile

@obestwalter obestwalter added area:configuration feature:new something does not exist yet, but should level:hard rought estimate that this might be quite hard to implement needs:discussion It's not quite clear if and how this should be done labels Sep 15, 2017
@The-Compiler
Copy link
Member

The-Compiler commented Sep 15, 2017

As mentioned there I'd prefer brackets because:

The syntax with brackets I proposed was inspired by the interpolation syntax in tox.ini where you'd use {[testenv:py35]basepython} as well, so I think it'd make sense to keep that syntax.

I'm fine with both though.

@obestwalter
Copy link
Member Author

The opposite approach would be: don't do this at all and instead focus on improving the documentation to show clearly that all these things (and more) can be accomplished with environment variables and substitutions in tox.ini.

I personally would prefer this approach because we don't have to write even one single line of code for that.

@RonnyPfannschmidt
Copy link

as faras i can tell, implementing this right now as is would cement the config file format as ini files

@obestwalter
Copy link
Member Author

@RonnyPfannschmidt that is another important point keeping #600 in mind. If this would be implemented at all then the syntax should be config file agnostic.

@The-Compiler
Copy link
Member

The nice thing about having -o is that I don't need to modify the tox.ini at all.

For example, if I want to contribute to some project, and it does something in its tox.ini I disagree with (say, set a basepython which is different on my system). However, I want to use tox to run the tests locally because it makes my life easier.

Right now, I need to edit tox.ini accordingly, do my contributions, and then make sure to not accidentally commit the tox.ini changes I made. With an -o, I can simply override it one-time at the commandline.

@obestwalter
Copy link
Member Author

obestwalter commented Sep 15, 2017

The nice thing about having -o is that I don't need to modify the tox.ini at all.
[...]
Right now, I need to edit tox.ini accordingly, do my contributions, and then make sure to not accidentally commit the tox.ini changes I made. With an -o, I can simply override it one-time at the commandline.

True. From that POV it might actually be worth the effort.

@obestwalter obestwalter changed the title RFC: generic Configuration manipulation from the command line -o RFC: generic configuration manipulation from the command line Sep 15, 2017
@asottile
Copy link
Contributor

Instead of -o option option option, I'd suggest -o option -o option -o option as this will allow non ambiguous parsing (in my experience nargs='+' on options just doesn't work well as it then has to be the last thing on the command line)

@asottile
Copy link
Contributor

Ideally this should also deprecate the other cli options such as --skip-missing-interpreters as well (these can probably be reimplemented using this new option interface)

@obestwalter
Copy link
Member Author

Ideally this should also deprecate the other cli options such as --skip-missing-interpret

I think so too. These can go in 3.0 then :)

@gaborbernat gaborbernat added this to the 4.0 milestone May 2, 2019
@gaborbernat gaborbernat added the help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. label May 2, 2019
@obestwalter obestwalter mentioned this issue Jun 1, 2019
6 tasks
@gaborbernat
Copy link
Member

4.0 alpha now contains this via the -x or `--override`` flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:configuration feature:new something does not exist yet, but should help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. level:hard rought estimate that this might be quite hard to implement needs:discussion It's not quite clear if and how this should be done
Projects
None yet
Development

No branches or pull requests

5 participants