Skip to content

Fix duplicate values in Config.known_args_namespace for append actions#14422

Merged
bluetech merged 1 commit intopytest-dev:mainfrom
EternalRights:fix-known-args-namespace-duplicate
Apr 29, 2026
Merged

Fix duplicate values in Config.known_args_namespace for append actions#14422
bluetech merged 1 commit intopytest-dev:mainfrom
EternalRights:fix-known-args-namespace-duplicate

Conversation

@EternalRights
Copy link
Copy Markdown
Contributor

Ran into #13484 while looking at the config parsing code. The third parse_known_args call passes self.known_args_namespace as the namespace, which already has values from the second parse. For action="append" options like -W, this causes duplicates.

Fix is to use copy.copy(self.option) instead, same as the first two calls. This way each parse starts from a clean namespace and append actions don't accumulate across multiple parses.

Not sure if there was a reason the third call used known_args_namespace directly, but from what I can tell the only new things after the second parse are plugin-registered options, and those would still be picked up correctly with a fresh namespace.

Closes #13484

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Apr 26, 2026
@bluetech bluetech force-pushed the fix-known-args-namespace-duplicate branch from ebca589 to e178744 Compare April 29, 2026 08:34
Copy link
Copy Markdown
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Thanks, I think reparsing with self.option instead of self.known_args_namespace makes sense, in face of append actions.

I added some code comments for clarity.

@bluetech bluetech enabled auto-merge April 29, 2026 08:36
@bluetech bluetech merged commit 602fc18 into pytest-dev:main Apr 29, 2026
33 checks passed
@EternalRights
Copy link
Copy Markdown
Contributor Author

Thanks, I think reparsing with self.option instead of self.known_args_namespace makes sense, in face of append actions.

I added some code comments for clarity.

Thanks for reviewing and adding those comments, makes it much clearer now!

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.

Config.known_args_namespace contains duplicate value

2 participants