Skip to content

Conversation

gomri15
Copy link
Contributor

@gomri15 gomri15 commented Sep 26, 2025

  • Added flag to skip attempting to generate parametrization ids and just raise error on duplicate ids during collection

Closes #13737

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 26, 2025
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Should i documentation like there is for --collect-only?

Yes please - and then I think we'll be ready to merge 🙂

@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch 2 times, most recently from 907cf3e to 8a770c9 Compare September 27, 2025 16:44
@gomri15
Copy link
Contributor Author

gomri15 commented Sep 27, 2025

Should i documentation like there is for --collect-only?

Yes please - and then I think we'll be ready to merge 🙂

Is this till needed or did with @nicoddemus say cover this?

@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch 2 times, most recently from c0ce285 to a07ff8a Compare September 27, 2025 17:01
@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch from 35da7df to 4d6fa15 Compare October 1, 2025 07:09
@gomri15 gomri15 requested a review from Zac-HD October 1, 2025 07:10
@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch 3 times, most recently from 71152b2 to 9cebbab Compare October 1, 2025 19:45
Copy link
Contributor Author

@gomri15 gomri15 left a comment

Choose a reason for hiding this comment

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

Done all fixes

@nicoddemus
Copy link
Member

@Zac-HD just realized something: doesn't make more sense for this to be an ini option rather than a command-line flag? I understand this is something one would like to setup permanently for a test suite, rather than something to be passed on the command line on occasion.

@Zac-HD
Copy link
Member

Zac-HD commented Oct 3, 2025

doesn't make more sense for this to be an ini option rather than a command-line flag?

Ideally both, I guess?

@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch from b1bae36 to b825eb4 Compare October 3, 2025 11:41
@gomri15
Copy link
Contributor Author

gomri15 commented Oct 3, 2025

doesn't make more sense for this to be an ini option rather than a command-line flag?

Ideally both, I guess?

@nicoddemus, @Zac-HD
added support for the ini flag and tests for it.

@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch 4 times, most recently from 03b31f8 to 358627e Compare October 3, 2025 19:28
@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch from 358627e to f547106 Compare October 11, 2025 09:08
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Minor edits to the docs, and then I'll give @nicoddemus a few days to comment, and then merge!

@bluetech
Copy link
Member

just realized something: doesn't make more sense for this to be an ini option rather than a command-line flag? I understand this is something one would like to setup permanently for a test suite, rather than something to be passed on the command line on occasion.

FWIW I agree with this, I don't see a reason for this to be a CLI flag, only ini. Having fewer flags is generally a good thing.

In the future we could also consider adding it to the planned strict setting. A while ago we deprecated and removed strict with the intention of re-adding it such that it enabled various "strict" options, like this one. Though I do reckon that if we add it it should be as an INI flag not CLI.

@gomri15
Copy link
Contributor Author

gomri15 commented Oct 12, 2025

I understand wanting to have fewer flags to reduce complexity and setup pain.

Because we can get the same results from an ini and most likely, this parameter wills be set at the level of the whole execution and not just a few tests being run

Would you like me to remove the cli flag oart of this pr and leave the ini?

Copy link
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.

Some comments from me. I think this can be a nice strictness flag.

@bluetech
Copy link
Member

Thanks for the input bluetech, would you like me to remove the cli flag oart of this pr and leave the ini?

I'll let @Zac-HD decide, I don't feel strongly about it.

@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch 3 times, most recently from 57b5f00 to 9a1d479 Compare October 14, 2025 10:48
@gomri15
Copy link
Contributor Author

gomri15 commented Oct 14, 2025

@bluetech I went over and fixed all your comments, thanks for the input.

Main changes made:

  • rename flag to - "require-unique-parameterization-ids" i agree it's much more readable and would be easier for pytest users to understand
  • Added fix suggestion to error message (it might be too explicit, but I was thinking it would be nice for the message to be a one stop shop for solving the problem)
  • Inlined testing until function which called create testfile
  • Improved wording of description for clarity.

@gomri15 gomri15 requested review from Zac-HD and bluetech October 14, 2025 12:04
@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch from 9a1d479 to 4782ea6 Compare October 14, 2025 12:05
Copy link
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 for the update! Please see my comments below.

@bluetech
Copy link
Member

Thanks for the input bluetech, would you like me to remove the cli flag oart of this pr and leave the ini?

I'll let @Zac-HD decide, I don't feel strongly about it.

BTW, if we go with ini only, I think it would make sense to use the name strict_parametrization_ids or such, similar to strict_xfail, to indicate it's a strictness flag. And if in the future we add the strict ini it'd be clear that it's part of it.

@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch 3 times, most recently from 9d7870a to 4eaf20e Compare October 14, 2025 20:53
@gomri15 gomri15 requested a review from bluetech October 15, 2025 18:53
@gomri15 gomri15 force-pushed the 13737-require-unique-paramset-ids branch from 4eaf20e to 767a11f Compare October 17, 2025 13:09
@gomri15
Copy link
Contributor Author

gomri15 commented Oct 17, 2025

@bluetech Fixed all the comments is there anything else you think needs doing?

@bluetech
Copy link
Member

@gomri15 Instead of another round of pedantic comments, I pushed a commit with the changes I thought about. Some comments:

  • I made an "executive decision" to rename the param to strict_parametrization_ids and remove the CLI flag. Should tie in with --strict deprecation was botched - what to do about it #13823.
  • Tweaks the comments/messages a bit.
  • Simplified the test a bit.
  • Added handling of pytest.HIDDEN_PARAM
  • As a separate commit, enabled the flag in pytest's own test suite (always good to "dogfood") and fixed the couple of issues it found (which were actual useless duplicates!).

Please take a look at the changes and let me know what you think. If it's good I can merge.

id if id is not HIDDEN_PARAM else "<hidden>" for id in resolved_ids
)
duplicates = ", ".join(
id if id is not HIDDEN_PARAM else "<hidden>"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not a blocker or a reason not to merge.
this is a pattern that does repeat itself a few times in the code
id if id is not HIDDEN_PARAM else "<hidden>"

Copy link
Member

Choose a reason for hiding this comment

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

I use https://en.wikipedia.org/wiki/Rule_of_three_(computer_programming) for this :)

It's a little repetition but close together and unlikely to get out of sync. So I prefer making the code more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha i like it 2 is just under 3 haha

@gomri15
Copy link
Contributor Author

gomri15 commented Oct 19, 2025

@bluetech Thank you very much for getting this a cross the line, really appreciate your input and I'll make a point of growing from it.

the changes look good to me.
I just added myself to Authors.

@bluetech bluetech force-pushed the 13737-require-unique-paramset-ids branch from cca6f1c to 5df54c6 Compare October 19, 2025 13:25
@bluetech bluetech merged commit ebcd836 into pytest-dev:main Oct 19, 2025
33 checks passed
@bluetech
Copy link
Member

Merged, thanks @gomri15 it was a great first PR. I will definitely use this option in my own projects.

@gomri15
Copy link
Contributor Author

gomri15 commented Oct 19, 2025

Thank you @bluetech
I am looking forward to contributing more and taking the learning from this review forward.

Pleasure working with you

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.

New config option: require_unique_paramset_ids

4 participants