Skip to content

Commit d4deb7e

Browse files
committed
Fix the default for a provided config
1 parent 16c631a commit d4deb7e

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

crates/config/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const OPTIONS_STARTING_WITH_ALLOW: [&str; 4] = [
2121
"allow_empty_bodies",
2222
];
2323

24+
#[derive(Debug)]
2425
pub struct DiagnosticConfig {
2526
pub show_error_codes: bool,
2627
pub show_error_end: bool,

crates/config/src/searcher.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const CONFIG_NAMES: [&str; 4] = [
1818
//"~/.mypy.ini",
1919
];
2020

21+
#[derive(Debug)]
2122
pub struct FoundConfig {
2223
pub project_options: ProjectOptions,
2324
pub diagnostic_config: DiagnosticConfig,
@@ -45,7 +46,9 @@ pub fn find_config(
4546
mode = ModeChoice::Explicit(Mode::Mypy)
4647
}
4748
let result = initialize_config(vfs, &current_dir, config_path, s, mode)?;
48-
let project_options = result.0.unwrap_or_else(ProjectOptions::mypy_default);
49+
let project_options = result
50+
.0
51+
.unwrap_or_else(|| ProjectOptions::default_for_mode(mode.into()));
4952
Ok(FoundConfig {
5053
project_options,
5154
diagnostic_config: result.1,

crates/zmypy/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ mod tests {
11951195
let pyproject_zuban_section_only = |mode| write_pyproject_toml(true, false, mode);
11961196
let pyproject_both_sections = |mode| write_pyproject_toml(true, true, mode);
11971197
let pyproject_mypy_section_only = || write_pyproject_toml(false, true, None);
1198-
let pyproject_empty = || write_pyproject_toml(true, true, None);
1198+
let pyproject_empty = || write_pyproject_toml(false, false, None);
11991199

12001200
// Test in the following order with every explicit/implicit mode:
12011201
//
@@ -1303,7 +1303,7 @@ mod tests {
13031303
// (2d)
13041304
pyproject_empty();
13051305
assert!(!is_mypy_empty_args());
1306-
assert!(!is_mypy_in_auto_mode());
1306+
assert!(is_mypy_in_auto_mode());
13071307
}
13081308
test_dir.remove_file(file_name)
13091309
}

0 commit comments

Comments
 (0)