ruff/crates/ruff_cli
Charlie Marsh bf1a94ee54
Initialize caches for packages and standalone files (#5237)
## Summary

While fixing https://github.com/astral-sh/ruff/pull/5233, I noticed that
in FastAPI, 343 out of 823 files weren't hitting the cache. It turns out
these are standalone files in the documentation that lack a "package
root". Later, when looking up the cache entries, we fallback to the
package directory.

This PR ensures that we initialize the cache for both kinds of files:
those that are in a package, and those that aren't.

The total size of the FastAPI cache for me is now 388K. I also suspect
that this approach is much faster than as initially written, since
before, we were probably initializing one cache per _directory_.

## Test Plan

Ran `cargo run -p ruff_cli -- check ../fastapi --verbose`; verified
that, on second execution, there were no "Checking" entries in the logs.
2023-06-21 17:29:09 +00:00
..
resources/test/fixtures/cache_mutable Open cache files in parallel (#5120) 2023-06-20 17:43:09 +02:00
src Initialize caches for packages and standalone files (#5237) 2023-06-21 17:29:09 +00:00
tests Add rule documentation URL to JSON output (#5187) 2023-06-19 21:09:15 +00:00
Cargo.toml Bump version to 0.0.274 (#5230) 2023-06-20 22:12:32 -04:00