FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

config: add support for ini option aliases by bluetech · Pull Request #13831 · pytest-dev/pytest · GitHub

config: add support for ini option aliases - #13831

Merged
bluetech merged 1 commit into
pytest-dev:mainfrom
bluetech:ini-aliases
Oct 22, 2025
Merged

config: add support for ini option aliases#13831
bluetech merged 1 commit into
pytest-dev:mainfrom
bluetech:ini-aliases

Conversation

Copy link
Copy Markdown
Member

Fix #13829.

Currently based on #13830 -- please skip that commit.

psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 19, 2025

nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice work!

Comment thread testing/test_config.py Outdated
assert config.getini("old_name") == "value1"
assert config.getini("legacy_name") == "value1"

def test_addini_aliases_with_override(self, pytester: Pytester) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Perhaps worth adding a test where the ini file uses the new name, and the cmdline override uses the old name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Great suggestion -- this case is actually broken. It worked in my version before #13830 but broke after it.

I pushed the broken test now, will work on the fix later.

One option is to revert #13830, but the version before was pretty unruly, I still think #13830 is a good idea.

My thinking is to track the origin of ini values in inicfg (change it from dict[str, str] to dict[str, IniValue] where IniValue contains the value and origin -- configuration file or cli override). Then we give priority to overrides even if they're alias and the canonical is defined. Maybe the origin can be used for better error messages as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sounds good. 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Implemented this, pushed as a separate commit (will squash before merging).

bluetech marked this pull request as draft October 21, 2025 14:34
bluetech marked this pull request as ready for review October 21, 2025 19:38

nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM!

nicoddemus commented Oct 22, 2025
edited
Loading

Copy link
Copy Markdown
Member

Btw your IniValue solution gives me the impression that augmenting it by adding the aliases to that dataclass might improve the code further (we would have a single class defining the values and the aliases, instead of that information being split in two dicts) -- but I have not thought about it in detail, plus it is a larger refactoring which I'm not sure you are willing to tackle now.

Copy link
Copy Markdown
Member Author

We want an alias -> canonical mapping, because it's used by the cached getini which should be quick. So I think it wouldn't end up better.

bluetech merged commit fd7742e into pytest-dev:main Oct 22, 2025
33 checks passed
bluetech deleted the ini-aliases branch October 22, 2025 12:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ini option aliases

2 participants


Back | FazBrowse Home | New Git URL