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

[FIX] TOML set_env from file #3478

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

juditnovak
Copy link

@juditnovak juditnovak commented Feb 5, 2025

This code change is addressing #3474, making sure that TOML config has the same support to apply set_env from file, as INI configuration does.


def replacer(raw_: str, args_: ConfigLoadArgs) -> str:
if conf is None:
replaced = raw_ # no replacement supported in the core section
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH this condition I've just taken from the INI correspondant... Pls double-check if it makes sense in TOML parsing context. Thanks.

@juditnovak juditnovak force-pushed the fix/toml_setenv_from_file branch from ab08b87 to 30ad161 Compare February 5, 2025 01:16
@juditnovak juditnovak force-pushed the fix/toml_setenv_from_file branch from 10c8e9c to 7dc1f78 Compare February 5, 2025 01:18
@juditnovak juditnovak marked this pull request as ready for review February 5, 2025 09:03
@juditnovak juditnovak changed the title [WIP] [FIX] TOML set_env from file [FIX] TOML set_env from file Feb 5, 2025
("conf_type", "config"),
[
("ini", "[testenv]\npackage=skip\nset_env=file|A{/}a.txt\nchange_dir=C"),
("toml", '[env_run_base]\npackage="skip"\nset_env="file|A{/}a.txt"\nchange_dir="C"'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make more sense that this to be a dictionary key rather than we just unroll a string. Something like 'set_env = [ { file= "a.txt"}] `.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure that I'm following correctly. Could you pls confirm that the following is what you suggest?

INI:

The current syntax supported for tox.ini for set_env:

[testenv]
set_env=file|<path>

TOML:

Moving away from the file| syntax introduced for tox.ini, benefitting from embedded data structures instead such as:

[env_run_base]
set_env=[{file=<path>}]

While this would raise an ERROR in TOML:

[env_run_base]
set_env="file|<path>"

Is this the direction you would like to take? Not to support file| terminology when TOML configuration is used?

(Sorry, I understood that a PR was welcome for the issue as raised -- which my attempt was aiming to respond. Of course, I'm glad to modify the code alongside a different design, if preferred. I agree that the above solution is more elegant.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, with the TOML format we generally are trying to move away from embedding information into strings, and instead use the rich type system and structure of the TOML language instead.

@gaborbernat
Copy link
Member

You still plan to tackle this?

@gaborbernat gaborbernat marked this pull request as draft February 10, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants