-
-
Notifications
You must be signed in to change notification settings - Fork 367
Clean up check.sh, move stuff to pre-commit #3157
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
Changes from all commits
9b3783f
84433f4
7557558
b38faba
17d3d05
4633591
22215d0
b4d08e1
8f787d6
2bc884c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,38 +17,6 @@ python ./src/trio/_tools/gen_exports.py --test \ | |||||
|| EXIT_STATUS=$? | ||||||
echo "::endgroup::" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I probably should do this in another PR but I think we should move gen exports out of pre-commit and back here. Unfortunately, as things currently are, if you modify a file that the pre-commit hook says it uses then commit with a git client (ie not just So far I've been getting that error then going to my terminal to run git there, but that's a bit much. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-commit with a external git client doesn't install required dependencies? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, because we don't specify them. We don't specify them because pre-commit doesn't let you install from a requirements file :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I specified them in the latest commit: Line 46 in 17d3d05
but that doesn't let us pin the versions (in a non-awful way), so yeah if we don't want that then it has to go outside of pre-commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Keep in mind that the pre-commit cache is virtually immortal. You can clean it locally, but not in the So I've found that the best thing to do here is to keep the version pins in the list and bump them periodically. Just so that the cache doesn't grow too old. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I'm personally a big fan of tox. #2790 discussed hatchling too but we ended up bikeshedding too much to actually do anything in the end. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be happy to switch to nox -- potentially or tox. I haven't used either and attrs uses tox so it can't be that bad, but https://hynek.me/articles/why-i-like-nox/ is convincing to me... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've yet to use nox, but would def be open to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've contributed to projects with nox, and they're slightly more inconvenient. I'd also want to run nox python files under coverage. one thing to bear in mind with tox is that constraints are a bit of a pain, tox-uv and a lock file seems the way to go: https://github.com/tox-dev/tox-uv?tab=readme-ov-file#uvlock-support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been taking DIY lock files to extremes with tox for a while. Haven't yet tried uv for that, really. I know that they were implementing the poetry-style format, not real lock files. I'm looking forward to seeing Brett's PEP accepted, honestly. I also have a lot more experience with tox and haven't contributed to nox. Although, I have contributed to projects using nox. There's limitations for parallelism, for example. Some scripting would be more convenient in Python. However, tox 4 has a |
||||||
|
||||||
# Autoformatter *first*, to avoid double-reporting errors | ||||||
# (we'd like to run further autoformatters but *after* merging; | ||||||
# see https://forum.bors.tech/t/pre-test-and-pre-merge-hooks/322) | ||||||
# autoflake --recursive --in-place . | ||||||
# pyupgrade --py3-plus $(find . -name "*.py") | ||||||
echo "::group::Black" | ||||||
if ! black --check src/trio; then | ||||||
echo "* Black found issues" >> "$GITHUB_STEP_SUMMARY" | ||||||
EXIT_STATUS=1 | ||||||
black --diff src/trio | ||||||
echo "::endgroup::" | ||||||
echo "::error:: Black found issues" | ||||||
else | ||||||
echo "::endgroup::" | ||||||
fi | ||||||
|
||||||
# Run ruff, configured in pyproject.toml | ||||||
echo "::group::Ruff" | ||||||
if ! ruff check .; then | ||||||
echo "* ruff found issues." >> "$GITHUB_STEP_SUMMARY" | ||||||
EXIT_STATUS=1 | ||||||
if $ON_GITHUB_CI; then | ||||||
ruff check --output-format github --diff . | ||||||
else | ||||||
ruff check --diff . | ||||||
fi | ||||||
echo "::endgroup::" | ||||||
echo "::error:: ruff found issues" | ||||||
else | ||||||
echo "::endgroup::" | ||||||
fi | ||||||
|
||||||
# Run mypy on all supported platforms | ||||||
# MYPY is set if any of them fail. | ||||||
MYPY=0 | ||||||
|
@@ -77,25 +45,11 @@ if [ $MYPY -ne 0 ]; then | |||||
fi | ||||||
|
||||||
# Check pip compile is consistent | ||||||
echo "::group::Pip Compile - Tests" | ||||||
uv pip compile --universal --python-version=3.9 test-requirements.in -o test-requirements.txt | ||||||
echo "::endgroup::" | ||||||
echo "::group::Pip Compile - Docs" | ||||||
uv pip compile --universal --python-version=3.11 docs-requirements.in -o docs-requirements.txt | ||||||
echo "::group::Pip Compile - Tests & Docs" | ||||||
pre-commit run pip-compile --all-files \ | ||||||
|| EXIT_STATUS=$? | ||||||
echo "::endgroup::" | ||||||
|
||||||
if git status --porcelain | grep -q "requirements.txt"; then | ||||||
echo "::error::requirements.txt changed." | ||||||
echo "::group::requirements.txt changed" | ||||||
echo "* requirements.txt changed" >> "$GITHUB_STEP_SUMMARY" | ||||||
git status --porcelain | ||||||
git --no-pager diff --color ./*requirements.txt | ||||||
EXIT_STATUS=1 | ||||||
echo "::endgroup::" | ||||||
fi | ||||||
|
||||||
codespell || EXIT_STATUS=$? | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (not the right line because github isn't letting me comment there) Should you remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realized we can't do My goal is not to require/expect people to run check.sh locally as it's unintuitive and clunky, but given the limitations of pre-commit we do need to stash these somewhere and make it easy for users to run them locally if they want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually wrap the pre-commit invocation in tox for local run anyway + run it in CI too, which covers the case of the service not having the internet during testing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also add a local system hook to pre-commit that runs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There's several problems with doing this currently:
So I don't ~ever run This def isn't super obvious for new contributors though, but tox/nox should help with that. E.g. in tox you can create a label for a collection of environments that is considered "standard" to run locally. |
||||||
|
||||||
echo "::group::Pyright interface tests" | ||||||
python src/trio/_tests/check_type_completeness.py || EXIT_STATUS=$? | ||||||
|
||||||
|
@@ -113,8 +67,7 @@ Problems were found by static analysis (listed above). | |||||
To fix formatting and see remaining errors, run | ||||||
|
||||||
uv pip install -r test-requirements.txt | ||||||
black src/trio | ||||||
ruff check src/trio | ||||||
pre-commit run --all-files | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hook stage manual? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I see, it might be worth using hook stage manual here, just in case any get added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it feels kinda weird suggesting people do stuff that is completely redundant/ineffective. And if we do add manual stages there's perhaps gonna be a decent reason we make them manual? Idk I'll leave it as is /shrug |
||||||
./check.sh | ||||||
|
||||||
in your local checkout. | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.