ruff/crates/ruff_cli/src/commands
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
..
add_noqa.rs Ignore pyproject.toml for adding noqa directives (#5013) 2023-06-11 20:21:24 -04:00
clean.rs Disallow unreachable_pub (#4314) 2023-05-11 18:00:00 -04:00
config.rs Rename ruff_python_semantic's Context struct to SemanticModel (#4565) 2023-05-22 02:35:03 +00:00
linter.rs Disallow unreachable_pub (#4314) 2023-05-11 18:00:00 -04:00
mod.rs Disallow unreachable_pub (#4314) 2023-05-11 18:00:00 -04:00
rule.rs Enable pycodestyle rules under new "nursery" category (#4407) 2023-05-16 21:21:58 +00:00
run.rs Initialize caches for packages and standalone files (#5237) 2023-06-21 17:29:09 +00:00
run_stdin.rs Create dummy format CLI (#4453) 2023-05-19 11:45:52 +02:00
show_files.rs Add option (-o/--output-file) to write output to a file (#4950) 2023-06-20 22:16:49 +05:30
show_settings.rs Add option (-o/--output-file) to write output to a file (#4950) 2023-06-20 22:16:49 +05:30