Add settings hash to cache (#20)

This commit is contained in:
Charlie Marsh 2022-08-20 13:37:21 -04:00 committed by GitHub
parent 4c62e1e22e
commit b63d66fc3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 31 deletions

View file

@ -1,15 +1,25 @@
use std::collections::HashSet;
use std::collections::BTreeSet;
use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
use crate::checks::CheckCode;
use anyhow::Result;
use crate::checks::CheckCode;
use crate::pyproject::load_config;
pub struct Settings {
pub line_length: usize,
pub exclude: Vec<PathBuf>,
pub select: HashSet<CheckCode>,
pub select: BTreeSet<CheckCode>,
}
impl Hash for Settings {
fn hash<H: Hasher>(&self, state: &mut H) {
self.line_length.hash(state);
for value in self.select.iter() {
value.hash(state);
}
}
}
impl Settings {
@ -30,7 +40,7 @@ impl Settings {
})
.collect(),
select: config.select.unwrap_or_else(|| {
HashSet::from([
BTreeSet::from([
CheckCode::F831,
CheckCode::F541,
CheckCode::F634,