Repository navigation
feat(rules): expose pytest_test rule for public use - #4244
Conversation
The pytest_test rule has gone through some great additions and I think it is time to advertise it to others as well. At the same time: - Add `pytest-randomly` and `pytest-shard`. The latter is optional dependency and used only the tests are sharded. - Move the rule to `private` and update callsites. - Add `pytest-randomly` to our lock file. Things that we could do in addition to this - Add `pip.dep` declarations. These may make the error messages easier to interpret? - Move pytest-bazel to `bazel-contrib/rules_python` or as a standalone project. Closes bazel-contrib#3594
rickeylev
left a comment
There was a problem hiding this comment.
imma have my agent post review comments and see how well it goes
| pytest_bazel, | ||
| ] | ||
| if pytest_randomly != None: | ||
| deps.append(pytest_randomly) |
There was a problem hiding this comment.
can't use append(); deps may be a select. use + instead.
did you use an agent to write this? Just asking because, if so, i'll go update the agent configs to have something like "for user-provided label list values, assume a select() is a valid input unless documented otherwise, so append() can't be used and + should be used instead"
rickeylev
left a comment
There was a problem hiding this comment.
Left a few review comments covering:
- External Bzlmod & visibility support (
python/private/pytest_test/BUILD.bazelandMODULE.bazel): thedefault_pytest*aliases needvisibility = NOT_ACTUALLY_PUBLICand@pypineeds to be visible to@rules_pythonwhen used as a non-root Bzlmod dependency. pytest_randomlyopt-out & macro helper tags (python/private/pytest_test/pytest_test.bzl): removing the redundant!= Nonecheck, documenting@rules_python//python:none(or an emptypy_librarytarget) to opt out ofpytest_randomly, and tagging_write_pytest_bootstrapwithtags = ["manual"].- Docs &
bzl_librarywiring (python/BUILD.bazel,docs/BUILD.bazel,python/pytest_test.bzl,news/4244.added.md): adding the//python:pytest_testbzl_librarytarget and registering it in//docs:bzl_api_docsso{obj}\pytest_test`` resolves in Sphinx. - Lockfile sync & tests (
dev/pyproject.toml,dev/requirements.txt,tests/pytest_test/): syncingdev/requirements.txtand adding test coverage forpytest_shard/pytest_randomly.
This is an agent-generated comment by His Magnanimous Celestial Eminence, Archangel Michael, Supreme Benevolent Sovereign of the Starlark Firmament.
Hm. We should add a test in a sub-module to check that things resolve OK. I don't know if we can have multiple |
rickeylev
left a comment
There was a problem hiding this comment.
LGTM in concept, so approved
Ensure pytest_test works cleanly for external Bzlmod consumers and meets project documentation and Starlark conventions: - Expose @pypi in non-dev use_repo(pip, ...) and mark default_pytest* aliases and bootstrap_template as NOT_ACTUALLY_PUBLIC. - Support select() in deps, tag _write_pytest_bootstrap as manual, and provide PyInfo from //python:none so callers can disable pytest-randomly. - Add //python:pytest_test bzl_library, Sphinx stardoc target, versionadded directives, and news issue link. - Add pytest-shard to dev/pyproject.toml, sync lockfiles, and expand pytest_test test coverage.
Explain that select() in pytest_default_test's deps verifies that pytest_test handles selector_list values when concatenating default and sharding dependencies.
Ensure @pypi//pytest, @pypi//pytest_bazel, @pypi//pytest_randomly, and @pypi//pytest_shard always exist in the unified @pypi hub so downstream consumers get helpful MissingPyPiDep errors instead of package loading errors when any of these dependencies are absent from their lockfile.
Add a dedicated rules_python Usage Auditor subagent and rules_python.md rule to verify Bzlmod pip.dep() declarations for @pypi targets under python/**, and require the 'do not merge' label when PR descriptions contain open questions.
…pytest-rule # Conflicts: # .agents/skills/create-pr/SKILL.md
|
Thanks! |
The pytest_test rule has gone through some great additions
and I think it is time to advertise it to others as well.
At the same time:
pytest-randomlyandpytest-shard. The latter is optionaldependency and used only the tests are sharded.
privateand update callsites.pytest-randomlyto our lock file.Things that we could do in addition to this
pip.depdeclarations. These may make the error messages easierto interpret?
bazel-contrib/rules_pythonor as a standaloneproject.
Closes #3594