Skip to content

treewide: pytestFlagsArray -> pytestFlags and join flag and option argument#416213

Merged
wolfgangwalther merged 4 commits intoNixOS:stagingfrom
ShamrockLee:pytestFlags-flags
Jun 15, 2025
Merged

treewide: pytestFlagsArray -> pytestFlags and join flag and option argument#416213
wolfgangwalther merged 4 commits intoNixOS:stagingfrom
ShamrockLee:pytestFlags-flags

Conversation

@ShamrockLee
Copy link
Contributor

This treewide change targets Python packages that specifies pytest flags with pytestFlagsArray, and whose flags cannot be consructed by other pytestCheckHook-honoured arguments.

Use the __structuredAttrs-agnostic argument pytestFlags instead of the deprecated pytestFlagsArray.

For flags with option arguments, join each flag and their option argument into a single command-line argument following POSIX Utility Argument Syntax for easier overriding (remove/replace).

Examples:

  • [ "-W" "ignore:message:WarningClass" ] -> [ "-Wignore:message:WarningClass" ]
  • [ "--reruns" "3" ] -> [ "--reruns=3" ]

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@ShamrockLee ShamrockLee added the 3.skill: trivial This is trivial to complete (typically find-and-replace) label Jun 12, 2025
@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab labels Jun 12, 2025
@ShamrockLee ShamrockLee added 3.skill: trivial This is trivial to complete (typically find-and-replace) and removed 3.skill: trivial This is trivial to complete (typically find-and-replace) labels Jun 12, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Jun 12, 2025
@ShamrockLee ShamrockLee marked this pull request as ready for review June 12, 2025 20:06
@nix-owners nix-owners bot requested review from mweinelt and thiagokokada June 12, 2025 20:08
@mweinelt mweinelt requested review from dotlambda and natsukium June 12, 2025 20:19
Comment on lines 46 to 47
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be -ppytester then?

Copy link
Contributor Author

@ShamrockLee ShamrockLee Jun 12, 2025

Choose a reason for hiding this comment

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

Unfortunately not. -p changes the way positional arguments are handled, similar to what the -f=file flag does to installables for nix commands.

Here's the pytest documentation: https://docs.pytest.org/en/stable/how-to/usage.html#early-loading-plugins

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't read from the docs why -ppytester doesn't work but all the -pno:... do work?

If one doesn't work, should we be consistent and never use it?

I mean.. I see the benefit for all the -W... options to put them into a single string. But actually for all the others I read, which includes -p and the famous -rfEs, I think this makes things worse. So maybe only do this for -W?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I confused -p with another flag that behaves the way I described.

Now I recalled the flag that behaves this way.

It's --pyargs

https://github.com/pytest-dev/pytest/blob/336cb917f7175ccc5a699f81b58f3587c5a7dcca/src/_pytest/main.py#L116-L120

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Those are consistently kept as multiple arguments, so should be good.

…gument

This treewide change targets Python packages
that specifies pytest flags with pytestFlagsArray,
and whose flags cannot be consructed by other pytestCheckHook-honoured arguments.

Use the __structuredAttrs-agnostic argument pytestFlags
instead of the deprecated pytestFlagsArray.

For flags with option arguments,
join each flag and their option argument into a single command-line argument
following POSIX Utility Argument Syntax[1]
for easier overriding (remove/replace).

Examples:

* [ "-W" "ignore:message:WarningClass" ] ->
  [ "-Wignore:message:WarningClass" ]

* [ "--reruns" "3" ] ->
  [ "--reruns=3" ]

[1]: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html
@github-actions github-actions bot added the 12.approvals: 2 This PR was reviewed and approved by two persons. label Jun 15, 2025
@wolfgangwalther wolfgangwalther merged commit d6c3987 into NixOS:staging Jun 15, 2025
12 of 16 checks passed
@wolfgangwalther
Copy link
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.skill: trivial This is trivial to complete (typically find-and-replace) 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants