Skip to content

Conversation

@serl
Copy link

@serl serl commented Aug 11, 2025

Closes #28

taplo lint supports the --cache-path argument to cache downloaded schemas. This adds the parameter if not passed already, using a directory in the activated venv.

taplo lint supports the --cache-path argument to cache downloaded schemas.
This adds the parameter if not passed already, using a directory in the activated venv.
@serl serl mentioned this pull request Aug 11, 2025
Copy link
Member

@redeboer redeboer left a comment

Choose a reason for hiding this comment

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

Looks good, but I have to check if it all works as expected. Some small comments below

name: taplo-lint
description: Lint TOML documents
entry: taplo lint
entry: cached-taplo-lint
Copy link
Member

Choose a reason for hiding this comment

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

Maybe better to have a separate hook? I don't want to temper with the default behaviour of taplo-lint.

Copy link
Author

Choose a reason for hiding this comment

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

I understand your concern, but I'd still "shadow" the original hook:

  • I suspect that most users just install the hook and forget, no fancy setup, no weird customizations, no reading docs when updating => having it "magically go faster" after a pre-commit autoupdate seems the best we can do.
  • Those who added --cache-path something shouldn't be impacted, since the wrapper takes this case into account (and does nothing when it's the case).

Sure things could break in other ways:

  • taplo lint changing the caching behavior
  • some Murphy laws 🤷

Of course you have the last word.

Comment on lines 8 to 12
args = sys.argv[1:]

if '--cache-path' not in args:
cache_path.mkdir(parents=True, exist_ok=True)
args.extend(['--cache-path', str(cache_path)])
Copy link
Member

Choose a reason for hiding this comment

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

I'd work with ArgumentParser here.

Copy link
Author

Choose a reason for hiding this comment

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

I tried a little but I'm not really getting it.
ArgumentParser main goal seems to be checking and preparing arguments passed to the script to be used by itself. In this case, we need to construct arguments to be passed to another command, while very much not parsing anything else (taplo does that by itself already - and we're not re-implementing it all, right? 🤔)

Could you give me an example on what you are thinking about?

Copy link
Author

@serl serl left a comment

Choose a reason for hiding this comment

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

Thanks for the very fast review!

(I added some simple tests to the wrapper in the meantime, just to be sure that it behaves)

name: taplo-lint
description: Lint TOML documents
entry: taplo lint
entry: cached-taplo-lint
Copy link
Author

Choose a reason for hiding this comment

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

I understand your concern, but I'd still "shadow" the original hook:

  • I suspect that most users just install the hook and forget, no fancy setup, no weird customizations, no reading docs when updating => having it "magically go faster" after a pre-commit autoupdate seems the best we can do.
  • Those who added --cache-path something shouldn't be impacted, since the wrapper takes this case into account (and does nothing when it's the case).

Sure things could break in other ways:

  • taplo lint changing the caching behavior
  • some Murphy laws 🤷

Of course you have the last word.

Comment on lines 8 to 12
args = sys.argv[1:]

if '--cache-path' not in args:
cache_path.mkdir(parents=True, exist_ok=True)
args.extend(['--cache-path', str(cache_path)])
Copy link
Author

Choose a reason for hiding this comment

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

I tried a little but I'm not really getting it.
ArgumentParser main goal seems to be checking and preparing arguments passed to the script to be used by itself. In this case, we need to construct arguments to be passed to another command, while very much not parsing anything else (taplo does that by itself already - and we're not re-implementing it all, right? 🤔)

Could you give me an example on what you are thinking about?

@serl serl requested a review from redeboer August 29, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable cache on linting

2 participants