Skip to content

Fix help sections for CLI options #13221

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

Merged
merged 5 commits into from
Feb 18, 2025

Conversation

The-Compiler
Copy link
Member

Probably best reviewed commit by commit. Notably, this fixes:

pytest-warnings:
  -W, --pythonwarnings PYTHONWARNINGS
                        Set which warnings to report, see -W option of Python itself
  --maxfail=num         Exit after first num failures or errors
  --strict-config       Any warnings encountered while parsing the `pytest` section of the configuration file raise errors
  --strict-markers      Markers not registered in the `markers` section of the configuration file raise errors
  --strict              (Deprecated) alias to --strict-markers
  -c, --config-file FILE
                        Load configuration from `FILE` instead of trying to locate one of the implicit configuration files.
  --continue-on-collection-errors
                        Force test execution even if collection errors occur
  --rootdir=ROOTDIR     Define root directory for tests. Can be relative path: 'root_dir', './root_dir', 'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: '$HOME/root_dir'.

which makes no sense for anything except the first option, and is a regression in 19e99ab.

Other than that, it moves:

  • --continue-on-collection-errors to "collection" rather than "general"
  • --config-file and --rootdir to "test session [...] configuration" (where we also have things like --basetemp and --override-ini) instead of "general"

Finally, it cleans up incorrectly cargo-culted usage of group._addoption instead of group.addoption.

Not sure if this needs a changelog?

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the cleanup!

I think a "trivial" changelog is good to have, given this is a minor but still user facing change.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Feb 15, 2025
@The-Compiler The-Compiler added the backport 8.3.x apply to PRs at any point; backports the changes to the 8.3.x branch label Feb 15, 2025
Before:

    pytest-warnings:
      -W, --pythonwarnings PYTHONWARNINGS
                            Set which warnings to report, see -W option of Python itself
      --maxfail=num         Exit after first num failures or errors
      --strict-config       Any warnings encountered while parsing the `pytest` section of the configuration file raise errors
      --strict-markers      Markers not registered in the `markers` section of the configuration file raise errors
      --strict              (Deprecated) alias to --strict-markers
      -c, --config-file FILE
                            Load configuration from `FILE` instead of trying to locate one of the implicit configuration files.
      --continue-on-collection-errors
                            Force test execution even if collection errors occur
      --rootdir=ROOTDIR     Define root directory for tests. Can be relative path: 'root_dir', './root_dir', 'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: '$HOME/root_dir'.

But other than -W, those options aren't related to pytest-warnings at all.

This is a regression in 19e99ab, which added
`group = parser.getgroup("pytest-warnings")` in the middle of those "general"
options, thus moving the help section for some of them.
Moves --continue-on-collection-errors to "collection:"
"test session [...] configuration" seems more fitting than "general"
The only differences between the two is that:

- `addoption` checks for conflicts, but `_addoption` does not
- `addoption` complains if a lower-case short option is given,
  `_addoption` does not

Yet it looks like using the latter has been inconsistently cargo-culted with
newer options.
@The-Compiler
Copy link
Member Author

Added changelog and rebased (no other changes). We don't have a trivial changelog category anymore, so I went for doc over misc.

Any opinions on whether to backport this (IMHO yes), and whether to squash-merge (IMHO no)?

@nicoddemus
Copy link
Member

nicoddemus commented Feb 18, 2025

Any opinions on whether to backport this (IMHO yes)

IMHO no, I prefer to stick to docs-only and bugs-only for patch releases -- although this could be considered "doc", is still output from running pytest, who knows who might be parsing this and possibly breaking due to it changing? But I understand this is really low risk, so is not a strong stance, so please go ahead if you would like to see this in the next patch release.

and whether to squash-merge (IMHO no)?

Agreed!

@The-Compiler The-Compiler merged commit b0caf3d into pytest-dev:main Feb 18, 2025
28 checks passed
Copy link

patchback bot commented Feb 18, 2025

Backport to 8.3.x: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply b0caf3d on top of patchback/backports/8.3.x/b0caf3d7adc45f773177424593431869fd2f82d8/pr-13221

Backporting merged PR #13221 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/pytest-dev/pytest.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/8.3.x/b0caf3d7adc45f773177424593431869fd2f82d8/pr-13221 upstream/8.3.x
  4. Now, cherry-pick PR Fix help sections for CLI options #13221 contents into that branch:
    $ git cherry-pick -x b0caf3d7adc45f773177424593431869fd2f82d8
    If it'll yell at you with something like fatal: Commit b0caf3d7adc45f773177424593431869fd2f82d8 is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x b0caf3d7adc45f773177424593431869fd2f82d8
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Fix help sections for CLI options #13221 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/8.3.x/b0caf3d7adc45f773177424593431869fd2f82d8/pr-13221
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@The-Compiler
Copy link
Member Author

Whoops, I agree with what you said but forgot I already put the backport label on. Let's just leave it un-backported, given that nobody noticed the bugfix part for almost 4.5 years, I'm not in a hurry. 😅

@The-Compiler The-Compiler removed the backport 8.3.x apply to PRs at any point; backports the changes to the 8.3.x branch label Feb 18, 2025
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.

2 participants