mirror of https://github.com/astral-sh/ruff
Rename to iter_python_files
This commit is contained in:
parent
53905f6af3
commit
8b2a5f94ae
|
|
@ -2,7 +2,7 @@ use std::path::PathBuf;
|
|||
use std::sync::mpsc::channel;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use ::rust_python_linter::fs::collect_python_files;
|
||||
use ::rust_python_linter::fs::iter_python_files;
|
||||
use ::rust_python_linter::linter::check_path;
|
||||
use ::rust_python_linter::logging::set_up_logging;
|
||||
use ::rust_python_linter::message::Message;
|
||||
|
|
@ -32,7 +32,7 @@ struct Cli {
|
|||
fn run_once(files: &[PathBuf], cache: bool) -> Result<Vec<Message>> {
|
||||
// Collect all the files to check.
|
||||
let start = Instant::now();
|
||||
let files: Vec<DirEntry> = files.iter().flat_map(collect_python_files).collect();
|
||||
let files: Vec<DirEntry> = files.iter().flat_map(iter_python_files).collect();
|
||||
let duration = start.elapsed();
|
||||
debug!("Identified files to lint in: {:?}", duration);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,11 @@ fn is_not_hidden(entry: &DirEntry) -> bool {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn collect_python_files(path: &PathBuf) -> Vec<DirEntry> {
|
||||
pub fn iter_python_files(path: &PathBuf) -> impl Iterator<Item = DirEntry> {
|
||||
WalkDir::new(path)
|
||||
.follow_links(true)
|
||||
.into_iter()
|
||||
.filter_entry(is_not_hidden)
|
||||
.filter_map(|entry| entry.ok())
|
||||
.filter(|entry| entry.path().to_string_lossy().ends_with(".py"))
|
||||
.collect()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue