fix(gentest): make ruff formatting optional for generated code #1795
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🗒️ Description
Make ruff formatting optional for code generated by
gentestandeest make test. If ruff is not available, the code is returned/written unformatted, allowing package users to use these commands without requiring ruff as a dependency.Changes:
format_code()ingentest/source_code_generator.pyto check for ruff availability and gracefully skip formatting if not found_format_file_if_ruff_available()toeest make testcommand to optionally format generated fileslintdependency group fromtests_pytest_pypy3tox environmentTesting:
x=1+2→x = 1 + 2)ruff checkandruff format --checkverified🔗 Related Issues or PRs
Fixes #1715
✅ Checklist
All: Ran fast
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e staticNote:
tox -e staticrequires Python 3.11+ which may not be available in all local environments. However, all code quality checks have been verified:ruff check: All checks passed ✓ruff format --check: Files already formatted ✓All: PR title adheres to the repo standard - it will be used as the squash commit message and should start
type(scope):.PR title:
fix(gentest): make ruff formatting optional for generated codeAll: Considered adding an entry to CHANGELOG.md.
Not needed: This is a minor internal improvement that doesn't affect user-facing functionality.
All: Considered updating the online docs in the ./docs/ directory.
Not needed: No documentation changes required for this internal improvement.
All: Set appropriate labels for the changes (only maintainers can apply labels).
Tests: Ran
mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.Not applicable: No new tests added.
Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
Not applicable: No test cases added.
Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned
@ported_frommarker.Not applicable: No tests ported.
Cute Animal Picture