refactor: Use ..Options::default() for tests

This commit is contained in:
Martin Fischer 2023-01-24 06:17:36 +01:00 committed by Charlie Marsh
parent b29b4084ff
commit 3de2a57416
2 changed files with 13 additions and 587 deletions

View file

@ -429,54 +429,9 @@ mod tests {
None, None,
)?; )?;
let expected = Pyproject::new(Options { let expected = Pyproject::new(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
format: None,
force_exclude: None,
ignore: Some(vec![]), ignore: Some(vec![]),
ignore_init_module_imports: None,
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]), select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]),
show_source: None, ..Options::default()
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}); });
assert_eq!(actual, expected); assert_eq!(actual, expected);
@ -494,54 +449,10 @@ mod tests {
Some(vec![]), Some(vec![]),
)?; )?;
let expected = Pyproject::new(Options { let expected = Pyproject::new(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
format: None,
force_exclude: None,
ignore: Some(vec![]), ignore: Some(vec![]),
ignore_init_module_imports: None,
line_length: Some(100), line_length: Some(100),
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]), select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]),
show_source: None, ..Options::default()
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}); });
assert_eq!(actual, expected); assert_eq!(actual, expected);
@ -559,54 +470,10 @@ mod tests {
Some(vec![]), Some(vec![]),
)?; )?;
let expected = Pyproject::new(Options { let expected = Pyproject::new(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
format: None,
force_exclude: None,
ignore: Some(vec![]), ignore: Some(vec![]),
ignore_init_module_imports: None,
line_length: Some(100), line_length: Some(100),
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]), select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]),
show_source: None, ..Options::default()
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}); });
assert_eq!(actual, expected); assert_eq!(actual, expected);
@ -624,54 +491,9 @@ mod tests {
Some(vec![]), Some(vec![]),
)?; )?;
let expected = Pyproject::new(Options { let expected = Pyproject::new(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
format: None,
force_exclude: None,
ignore: Some(vec![]), ignore: Some(vec![]),
ignore_init_module_imports: None,
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]), select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]),
show_source: None, ..Options::default()
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}); });
assert_eq!(actual, expected); assert_eq!(actual, expected);
@ -689,59 +511,15 @@ mod tests {
Some(vec![]), Some(vec![]),
)?; )?;
let expected = Pyproject::new(Options { let expected = Pyproject::new(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
format: None,
force_exclude: None,
ignore: Some(vec![]), ignore: Some(vec![]),
ignore_init_module_imports: None,
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]), select: Some(vec![RuleSelector::E, RuleSelector::F, RuleSelector::W]),
show_source: None,
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: Some(flake8_quotes::settings::Options { flake8_quotes: Some(flake8_quotes::settings::Options {
inline_quotes: Some(flake8_quotes::settings::Quote::Single), inline_quotes: Some(flake8_quotes::settings::Quote::Single),
multiline_quotes: None, multiline_quotes: None,
docstring_quotes: None, docstring_quotes: None,
avoid_escape: None, avoid_escape: None,
}), }),
flake8_tidy_imports: None, ..Options::default()
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}); });
assert_eq!(actual, expected); assert_eq!(actual, expected);
@ -762,61 +540,17 @@ mod tests {
Some(vec![Plugin::Flake8Docstrings]), Some(vec![Plugin::Flake8Docstrings]),
)?; )?;
let expected = Pyproject::new(Options { let expected = Pyproject::new(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
format: None,
force_exclude: None,
ignore: Some(vec![]), ignore: Some(vec![]),
ignore_init_module_imports: None,
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: Some(vec![ select: Some(vec![
RuleSelector::D, RuleSelector::D,
RuleSelector::E, RuleSelector::E,
RuleSelector::F, RuleSelector::F,
RuleSelector::W, RuleSelector::W,
]), ]),
show_source: None,
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: Some(pydocstyle::settings::Options { pydocstyle: Some(pydocstyle::settings::Options {
convention: Some(Convention::Numpy), convention: Some(Convention::Numpy),
}), }),
pylint: None, ..Options::default()
pyupgrade: None,
}); });
assert_eq!(actual, expected); assert_eq!(actual, expected);
@ -834,64 +568,20 @@ mod tests {
None, None,
)?; )?;
let expected = Pyproject::new(Options { let expected = Pyproject::new(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
format: None,
force_exclude: None,
ignore: Some(vec![]), ignore: Some(vec![]),
ignore_init_module_imports: None,
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: Some(vec![ select: Some(vec![
RuleSelector::E, RuleSelector::E,
RuleSelector::F, RuleSelector::F,
RuleSelector::Q, RuleSelector::Q,
RuleSelector::W, RuleSelector::W,
]), ]),
show_source: None,
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: Some(flake8_quotes::settings::Options { flake8_quotes: Some(flake8_quotes::settings::Options {
inline_quotes: Some(flake8_quotes::settings::Quote::Single), inline_quotes: Some(flake8_quotes::settings::Quote::Single),
multiline_quotes: None, multiline_quotes: None,
docstring_quotes: None, docstring_quotes: None,
avoid_escape: None, avoid_escape: None,
}), }),
flake8_tidy_imports: None, ..Options::default()
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}); });
assert_eq!(actual, expected); assert_eq!(actual, expected);

View file

@ -163,56 +163,7 @@ mod tests {
assert_eq!( assert_eq!(
pyproject.tool, pyproject.tool,
Some(Tools { Some(Tools {
ruff: Some(Options { ruff: Some(Options::default())
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
force_exclude: None,
format: None,
ignore: None,
ignore_init_module_imports: None,
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: None,
show_source: None,
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
})
}) })
); );
@ -227,54 +178,8 @@ line-length = 79
pyproject.tool, pyproject.tool,
Some(Tools { Some(Tools {
ruff: Some(Options { ruff: Some(Options {
allowed_confusables: None,
builtins: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
force_exclude: None,
format: None,
ignore: None,
ignore_init_module_imports: None,
line_length: Some(79), line_length: Some(79),
namespace_packages: None, ..Options::default()
per_file_ignores: None,
respect_gitignore: None,
required_version: None,
select: None,
show_source: None,
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
cache_dir: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}) })
}) })
); );
@ -290,54 +195,8 @@ exclude = ["foo.py"]
pyproject.tool, pyproject.tool,
Some(Tools { Some(Tools {
ruff: Some(Options { ruff: Some(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: Some(vec!["foo.py".to_string()]), exclude: Some(vec!["foo.py".to_string()]),
extend: None, ..Options::default()
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
force_exclude: None,
format: None,
ignore: None,
ignore_init_module_imports: None,
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: None,
show_source: None,
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}) })
}) })
); );
@ -353,54 +212,8 @@ select = ["E501"]
pyproject.tool, pyproject.tool,
Some(Tools { Some(Tools {
ruff: Some(Options { ruff: Some(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: None,
external: None,
fix: None,
fix_only: None,
fixable: None,
force_exclude: None,
format: None,
ignore: None,
ignore_init_module_imports: None,
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: Some(vec![RuleSelector::E501]), select: Some(vec![RuleSelector::E501]),
show_source: None, ..Options::default()
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}) })
}) })
); );
@ -417,54 +230,9 @@ ignore = ["E501"]
pyproject.tool, pyproject.tool,
Some(Tools { Some(Tools {
ruff: Some(Options { ruff: Some(Options {
allowed_confusables: None,
builtins: None,
cache_dir: None,
dummy_variable_rgx: None,
exclude: None,
extend: None,
extend_exclude: None,
extend_ignore: None,
extend_select: Some(vec![RuleSelector::RUF100]), extend_select: Some(vec![RuleSelector::RUF100]),
external: None,
fix: None,
fix_only: None,
fixable: None,
force_exclude: None,
format: None,
ignore: Some(vec![RuleSelector::E501]), ignore: Some(vec![RuleSelector::E501]),
ignore_init_module_imports: None, ..Options::default()
line_length: None,
namespace_packages: None,
per_file_ignores: None,
required_version: None,
respect_gitignore: None,
select: None,
show_source: None,
src: None,
target_version: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: None,
flake8_builtins: None,
flake8_errmsg: None,
flake8_pytest_style: None,
flake8_quotes: None,
flake8_tidy_imports: None,
flake8_implicit_str_concat: None,
flake8_import_conventions: None,
flake8_unused_arguments: None,
isort: None,
mccabe: None,
pep8_naming: None,
pycodestyle: None,
pydocstyle: None,
pylint: None,
pyupgrade: None,
}) })
}) })
); );
@ -516,44 +284,17 @@ other-attribute = 1
config, config,
Options { Options {
allowed_confusables: Some(vec!['', 'ρ', '']), allowed_confusables: Some(vec!['', 'ρ', '']),
builtins: None,
line_length: Some(88), line_length: Some(88),
fix: None,
fix_only: None,
exclude: None,
extend: None,
extend_exclude: Some(vec![ extend_exclude: Some(vec![
"excluded_file.py".to_string(), "excluded_file.py".to_string(),
"migrations".to_string(), "migrations".to_string(),
"with_excluded_file/other_excluded_file.py".to_string(), "with_excluded_file/other_excluded_file.py".to_string(),
]), ]),
select: None,
extend_select: None,
external: Some(vec!["V101".to_string()]), external: Some(vec!["V101".to_string()]),
ignore: None,
ignore_init_module_imports: None,
extend_ignore: None,
fixable: None,
format: None,
force_exclude: None,
namespace_packages: None,
unfixable: None,
typing_modules: None,
task_tags: None,
update_check: None,
cache_dir: None,
per_file_ignores: Some(FxHashMap::from_iter([( per_file_ignores: Some(FxHashMap::from_iter([(
"__init__.py".to_string(), "__init__.py".to_string(),
vec![RuleSelector::F401] vec![RuleSelector::F401]
)])), )])),
dummy_variable_rgx: None,
respect_gitignore: None,
required_version: None,
src: None,
target_version: None,
show_source: None,
flake8_annotations: None,
flake8_bandit: None,
flake8_bugbear: Some(flake8_bugbear::settings::Options { flake8_bugbear: Some(flake8_bugbear::settings::Options {
extend_immutable_calls: Some(vec![ extend_immutable_calls: Some(vec![
"fastapi.Depends".to_string(), "fastapi.Depends".to_string(),
@ -621,8 +362,6 @@ other-attribute = 1
"dd".to_string(), "dd".to_string(),
)])), )])),
}), }),
flake8_unused_arguments: None,
isort: None,
mccabe: Some(mccabe::settings::Options { mccabe: Some(mccabe::settings::Options {
max_complexity: Some(10), max_complexity: Some(10),
}), }),
@ -647,10 +386,7 @@ other-attribute = 1
]), ]),
staticmethod_decorators: Some(vec!["staticmethod".to_string()]), staticmethod_decorators: Some(vec!["staticmethod".to_string()]),
}), }),
pycodestyle: None, ..Options::default()
pydocstyle: None,
pylint: None,
pyupgrade: None,
} }
); );