Skip to content

Conversation

@jbampton
Copy link
Contributor

Updated .prettierignore to ignore the typical Python environment files from .venv

If you are running pre-commit locally you probably have a Python environment setup.

This PR speeds up the prettier hook and avoids multiple passes through the targetted files.

If you have a look at this job run:

https://github.com/mruby/mruby/actions/runs/20506201194/job/58921074132

You will see that the pre-commit manual hooks failed for the prettier check.

You can see there in the list of files under the prettier failed hook that there is the main group of files but they are repeated about 4 times in the list. So prettier is doing about 4 passes through file list and extra over head etc.

And now my terminal log with a git explanation of how I tested this by adding 3 extra lines to the end of docker-compose.yml and then running prettier locally and the files list is only printed once as in each file path is listed only once. Right at the end of the list only the docker compose file was formatted

mruby$ git log --oneline -n 1
3c7d19d41 (HEAD -> cleanup-prettier-pre-commit, origin/cleanup-prettier-pre-commit) prettier: set `pass_filenames: false` to avoid multiple passes

mruby$ git status
On branch cleanup-prettier-pre-commit
Your branch is up to date with 'origin/cleanup-prettier-pre-commit'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   docker-compose.yml

no changes added to commit (use "git add" and/or "git commit -a")
mruby$ git diff
diff --git a/docker-compose.yml b/docker-compose.yml
index ef6a2d6d4..cd199cae1 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -11,3 +11,6 @@ services:
       - LD=gcc
       - SKIP=check-executables-have-shebangs
     working_dir: /app
+
+
+
mruby$ pre-commit run prettier --all-files --hook-stage manual
run prettier.............................................................Failed
- hook id: prettier
- files were modified by this hook

.github/linters/mlc_config.json 17ms (unchanged)
CONTRIBUTING.md 42ms (unchanged)
doc/guides/compile.md 43ms (unchanged)
doc/guides/debugger.md 16ms (unchanged)
doc/guides/gc-arena-howto.md 16ms (unchanged)
doc/guides/hier.md 4ms (unchanged)
doc/guides/link.md 8ms (unchanged)
doc/guides/memory.md 11ms (unchanged)
doc/guides/mrbconf.md 22ms (unchanged)
doc/guides/mrbgems.md 33ms (unchanged)
doc/guides/symbol.md 8ms (unchanged)
doc/internal/boxing.md 5ms (unchanged)
doc/limitations.md 12ms (unchanged)
doc/mruby3.0.md 14ms (unchanged)
doc/mruby3.1.md 19ms (unchanged)
doc/mruby3.2.md 6ms (unchanged)
doc/mruby3.3.md 31ms (unchanged)
doc/mruby3.4.md 38ms (unchanged)
examples/mrbgems/c_and_ruby_extension_example/README.md 1ms (unchanged)
examples/mrbgems/c_extension_example/README.md 1ms (unchanged)
examples/mrbgems/cdata_extension_example/README.md 1ms (unchanged)
examples/mrbgems/mruby-YOUR-bigint/TODO-HINT.md 3ms (unchanged)
examples/mrbgems/ruby_extension_example/README.md 1ms (unchanged)
mrbgems/hal-posix-task/README.md 5ms (unchanged)
mrbgems/hal-win-task/README.md 5ms (unchanged)
mrbgems/mruby-array-ext/README.md 15ms (unchanged)
mrbgems/mruby-benchmark/README.md 8ms (unchanged)
mrbgems/mruby-bigint/README-fgmp.md 6ms (unchanged)
mrbgems/mruby-bigint/README.md 3ms (unchanged)
mrbgems/mruby-bin-config/README.md 3ms (unchanged)
mrbgems/mruby-bin-debugger/README.md 4ms (unchanged)
mrbgems/mruby-bin-mirb/README.md 5ms (unchanged)
mrbgems/mruby-bin-mrbc/README.md 4ms (unchanged)
mrbgems/mruby-bin-mruby/README.md 3ms (unchanged)
mrbgems/mruby-bin-strip/README.md 2ms (unchanged)
mrbgems/mruby-binding/README.md 8ms (unchanged)
mrbgems/mruby-catch/README.md 4ms (unchanged)
mrbgems/mruby-class-ext/README.md 5ms (unchanged)
mrbgems/mruby-cmath/README.md 5ms (unchanged)
mrbgems/mruby-compar-ext/README.md 4ms (unchanged)
mrbgems/mruby-compiler/README.md 2ms (unchanged)
mrbgems/mruby-complex/README.md 4ms (unchanged)
mrbgems/mruby-data/README.md 4ms (unchanged)
mrbgems/mruby-dir/README.md 3ms (unchanged)
mrbgems/mruby-encoding/README.md 4ms (unchanged)
mrbgems/mruby-enum-chain/README.md 4ms (unchanged)
mrbgems/mruby-enum-ext/README.md 16ms (unchanged)
mrbgems/mruby-enum-lazy/README.md 4ms (unchanged)
mrbgems/mruby-enumerator/README.md 5ms (unchanged)
mrbgems/mruby-errno/README.md 4ms (unchanged)
mrbgems/mruby-error/README.md 10ms (unchanged)
mrbgems/mruby-eval/README.md 3ms (unchanged)
mrbgems/mruby-hash-ext/README.md 20ms (unchanged)
mrbgems/mruby-io/README.md 12ms (unchanged)
mrbgems/mruby-kernel-ext/README.md 6ms (unchanged)
mrbgems/mruby-math/README.md 5ms (unchanged)
mrbgems/mruby-metaprog/README.md 6ms (unchanged)
mrbgems/mruby-method/README.md 7ms (unchanged)
mrbgems/mruby-numeric-ext/README.md 4ms (unchanged)
mrbgems/mruby-object-ext/README.md 3ms (unchanged)
mrbgems/mruby-objectspace/README.md 3ms (unchanged)
mrbgems/mruby-os-memsize/README.md 3ms (unchanged)
mrbgems/mruby-pack/README.md 10ms (unchanged)
mrbgems/mruby-proc-binding/README.md 3ms (unchanged)
mrbgems/mruby-proc-ext/README.md 4ms (unchanged)
mrbgems/mruby-random/README.md 10ms (unchanged)
mrbgems/mruby-range-ext/README.md 3ms (unchanged)
mrbgems/mruby-rational/README.md 3ms (unchanged)
mrbgems/mruby-set/README.md 8ms (unchanged)
mrbgems/mruby-sleep/README.md 1ms (unchanged)
mrbgems/mruby-socket/README.md 3ms (unchanged)
mrbgems/mruby-sprintf/README.md 10ms (unchanged)
mrbgems/mruby-strftime/README.md 6ms (unchanged)
mrbgems/mruby-string-ext/README.md 16ms (unchanged)
mrbgems/mruby-struct/README.md 4ms (unchanged)
mrbgems/mruby-symbol-ext/README.md 3ms (unchanged)
mrbgems/mruby-task/README.md 18ms (unchanged)
mrbgems/mruby-test/README.md 1ms (unchanged)
mrbgems/mruby-time/README.md 8ms (unchanged)
mrbgems/mruby-toplevel-ext/README.md 2ms (unchanged)
NEWS.md 26ms (unchanged)
README.md 10ms (unchanged)
SECURITY.md 8ms (unchanged)
TODO.md 2ms (unchanged)
.github/linters/.hadolint.yaml 6ms (unchanged)
.pre-commit-config.yaml 13ms (unchanged)
.github/dependabot.yml 1ms (unchanged)
.github/labeler.yml 3ms (unchanged)
.github/linters/.ls-lint.yml 1ms (unchanged)
.github/linters/.markdown-lint.yml 1ms (unchanged)
.github/linters/.rubocop.yml 1ms (unchanged)
.github/linters/.yaml-lint.yml 1ms (unchanged)
.github/workflows/build.yml 4ms (unchanged)
.github/workflows/codeql-analysis.yml 2ms (unchanged)
.github/workflows/coverage.yml 2ms (unchanged)
.github/workflows/labeler.yml 1ms (unchanged)
.github/workflows/ls-lint.yml 1ms (unchanged)
.github/workflows/oss-fuzz.yml 1ms (unchanged)
.github/workflows/pre-commit.yml 1ms (unchanged)
.github/workflows/release.yml 1ms (unchanged)
.github/workflows/super-linter.yml 2ms (unchanged)
.travis.yml 1ms (unchanged)
appveyor.yml 2ms (unchanged)
docker-compose.yml 1ms
mruby$

From Google:

"When to use pass_filenames: false

Directory-based linters/tools: Some tools, especially in languages like Go or Terraform, perform analysis based on the entire directory context. Passing individual files can lead to false positives (e.g., "unused symbol" errors).

Tools that manage their own file discovery: If your hook's entry command (e.g., a Makefile target or a specific CLI tool) already finds the required files to check, you should set pass_filenames: false to avoid passing extra command-line arguments that the tool might not handle correctly.

Performance: For large codebases, running a tool on the whole project (pass_filenames: false) might be slow. The default pass_filenames: true behavior is often recommended for faster local checks, as it only runs on the changed files.

Hooks that use always_run: true: When a hook is set to run regardless of which files have changed, you often also set pass_filenames: false so that the command runs once on the entire project as intended."


So the prettier hook uses an entry command that finds its own files:

entry: prettier --write '**/*.json' '**/*.md' '**/*.yaml' '**/*.yml'

Updated `.prettierignore` to ingnore the typical Python environment files from `.venv`

If you are running pre-commit locally you probably have a Python environment setup.

This PR speeds up the prettier hook and avoids multiple passes through the targetted files.
@jbampton jbampton requested a review from matz as a code owner December 29, 2025 16:19
@github-actions github-actions bot added the build label Dec 29, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @jbampton, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request optimizes the prettier pre-commit hook configuration to enhance performance and efficiency. By setting pass_filenames: false for the prettier hook and adding Python virtual environment directories (.venv) to the .prettierignore file, the changes aim to reduce redundant file processing and speed up local pre-commit checks and CI runs.

Highlights

  • Prettier Hook Optimization: Configured the prettier pre-commit hook to use pass_filenames: false. This change prevents the tool from receiving individual file paths and instead allows it to discover files on its own, thereby avoiding redundant processing and multiple passes.
  • Ignore Python Virtual Environments: Added .venv to the .prettierignore file. This ensures that Python virtual environment directories are explicitly excluded from prettier's formatting checks, preventing unnecessary processing of generated files.
  • Performance Improvement: These combined changes significantly speed up the prettier pre-commit hook by eliminating multiple passes over the same files and ignoring irrelevant environment directories, as validated by local testing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to fix an issue where the prettier pre-commit hook processes files multiple times by setting pass_filenames: false. It also correctly adds the .venv directory to .prettierignore.

While setting pass_filenames: false is the right direction, the current implementation is incomplete and will likely cause the prettier hook to fail by hanging in CI. A corresponding change to the hook's entry is required to make prettier scan for files correctly. I've left a detailed comment explaining the necessary fix. Once that is addressed, this PR will be a great improvement to the project's tooling.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant