mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 17:41:12 +00:00
Remove redundant settings
field from Checker
(#18845)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
0ce022e64e
commit
528ae8083b
99 changed files with 252 additions and 236 deletions
|
@ -34,7 +34,7 @@ pub(crate) fn bindings(checker: &Checker) {
|
|||
if binding.kind.is_bound_exception()
|
||||
&& binding.is_unused()
|
||||
&& !checker
|
||||
.settings
|
||||
.settings()
|
||||
.dummy_variable_rgx
|
||||
.is_match(binding.name(checker.source()))
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ pub(crate) fn bindings(checker: &Checker) {
|
|||
flake8_import_conventions::rules::unconventional_import_alias(
|
||||
checker,
|
||||
binding,
|
||||
&checker.settings.flake8_import_conventions.aliases,
|
||||
&checker.settings().flake8_import_conventions.aliases,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::UnaliasedCollectionsAbcSetImport) {
|
||||
|
|
|
@ -76,7 +76,7 @@ pub(crate) fn deferred_scopes(checker: &Checker) {
|
|||
flake8_type_checking::helpers::is_valid_runtime_import(
|
||||
binding,
|
||||
&checker.semantic,
|
||||
&checker.settings.flake8_type_checking,
|
||||
&checker.settings().flake8_type_checking,
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
|
@ -139,7 +139,7 @@ pub(crate) fn deferred_scopes(checker: &Checker) {
|
|||
if !shadowed.kind.is_argument() {
|
||||
continue;
|
||||
}
|
||||
if checker.settings.dummy_variable_rgx.is_match(name) {
|
||||
if checker.settings().dummy_variable_rgx.is_match(name) {
|
||||
continue;
|
||||
}
|
||||
let scope = &checker.semantic.scopes[binding.scope];
|
||||
|
@ -231,7 +231,7 @@ pub(crate) fn deferred_scopes(checker: &Checker) {
|
|||
| BindingKind::FromImport(..)
|
||||
| BindingKind::SubmoduleImport(..)
|
||||
| BindingKind::FutureImport
|
||||
) && checker.settings.dummy_variable_rgx.is_match(name)
|
||||
) && checker.settings().dummy_variable_rgx.is_match(name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ pub(crate) fn deferred_scopes(checker: &Checker) {
|
|||
&& binding.is_unused()
|
||||
&& !binding.is_nonlocal()
|
||||
&& !binding.is_global()
|
||||
&& !checker.settings.dummy_variable_rgx.is_match(name)
|
||||
&& !checker.settings().dummy_variable_rgx.is_match(name)
|
||||
&& !matches!(
|
||||
name,
|
||||
"__tracebackhide__"
|
||||
|
|
|
@ -167,7 +167,7 @@ pub(crate) fn definitions(checker: &mut Checker) {
|
|||
if enforce_docstrings || enforce_pydoclint {
|
||||
if pydocstyle::helpers::should_ignore_definition(
|
||||
definition,
|
||||
&checker.settings.pydocstyle,
|
||||
&checker.settings().pydocstyle,
|
||||
&checker.semantic,
|
||||
) {
|
||||
continue;
|
||||
|
@ -253,7 +253,7 @@ pub(crate) fn definitions(checker: &mut Checker) {
|
|||
pydocstyle::rules::non_imperative_mood(
|
||||
checker,
|
||||
&docstring,
|
||||
&checker.settings.pydocstyle,
|
||||
&checker.settings().pydocstyle,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::SignatureInDocstring) {
|
||||
|
@ -292,7 +292,7 @@ pub(crate) fn definitions(checker: &mut Checker) {
|
|||
if enforce_sections || enforce_pydoclint {
|
||||
let section_contexts = pydocstyle::helpers::get_section_contexts(
|
||||
&docstring,
|
||||
checker.settings.pydocstyle.convention(),
|
||||
checker.settings().pydocstyle.convention(),
|
||||
);
|
||||
|
||||
if enforce_sections {
|
||||
|
@ -300,7 +300,7 @@ pub(crate) fn definitions(checker: &mut Checker) {
|
|||
checker,
|
||||
&docstring,
|
||||
§ion_contexts,
|
||||
checker.settings.pydocstyle.convention(),
|
||||
checker.settings().pydocstyle.convention(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ pub(crate) fn definitions(checker: &mut Checker) {
|
|||
definition,
|
||||
&docstring,
|
||||
§ion_contexts,
|
||||
checker.settings.pydocstyle.convention(),
|
||||
checker.settings().pydocstyle.convention(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ pub(crate) fn except_handler(except_handler: &ExceptHandler, checker: &Checker)
|
|||
except_handler,
|
||||
type_.as_deref(),
|
||||
body,
|
||||
checker.settings.flake8_bandit.check_typed_exception,
|
||||
checker.settings().flake8_bandit.check_typed_exception,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::TryExceptContinue) {
|
||||
|
@ -50,7 +50,7 @@ pub(crate) fn except_handler(except_handler: &ExceptHandler, checker: &Checker)
|
|||
except_handler,
|
||||
type_.as_deref(),
|
||||
body,
|
||||
checker.settings.flake8_bandit.check_typed_exception,
|
||||
checker.settings().flake8_bandit.check_typed_exception,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::ExceptWithEmptyTuple) {
|
||||
|
|
|
@ -35,7 +35,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
|||
&& checker.target_version() < PythonVersion::PY310
|
||||
&& checker.target_version() >= PythonVersion::PY37
|
||||
&& checker.semantic.in_annotation()
|
||||
&& !checker.settings.pyupgrade.keep_runtime_typing
|
||||
&& !checker.settings().pyupgrade.keep_runtime_typing
|
||||
{
|
||||
flake8_future_annotations::rules::future_rewritable_type_annotation(
|
||||
checker, value,
|
||||
|
@ -51,7 +51,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
|||
|| (checker.target_version() >= PythonVersion::PY37
|
||||
&& checker.semantic.future_annotations_or_stub()
|
||||
&& checker.semantic.in_annotation()
|
||||
&& !checker.settings.pyupgrade.keep_runtime_typing)
|
||||
&& !checker.settings().pyupgrade.keep_runtime_typing)
|
||||
{
|
||||
pyupgrade::rules::non_pep604_annotation(checker, expr, slice, operator);
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
|||
&& checker.target_version() < PythonVersion::PY39
|
||||
&& checker.target_version() >= PythonVersion::PY37
|
||||
&& checker.semantic.in_annotation()
|
||||
&& !checker.settings.pyupgrade.keep_runtime_typing
|
||||
&& !checker.settings().pyupgrade.keep_runtime_typing
|
||||
{
|
||||
flake8_future_annotations::rules::future_rewritable_type_annotation(checker, expr);
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
|||
|| (checker.target_version() >= PythonVersion::PY37
|
||||
&& checker.semantic.future_annotations_or_stub()
|
||||
&& checker.semantic.in_annotation()
|
||||
&& !checker.settings.pyupgrade.keep_runtime_typing)
|
||||
&& !checker.settings().pyupgrade.keep_runtime_typing)
|
||||
{
|
||||
pyupgrade::rules::use_pep585_annotation(
|
||||
checker,
|
||||
|
@ -395,7 +395,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
|||
&& checker.target_version() < PythonVersion::PY39
|
||||
&& checker.target_version() >= PythonVersion::PY37
|
||||
&& checker.semantic.in_annotation()
|
||||
&& !checker.settings.pyupgrade.keep_runtime_typing
|
||||
&& !checker.settings().pyupgrade.keep_runtime_typing
|
||||
{
|
||||
flake8_future_annotations::rules::future_rewritable_type_annotation(
|
||||
checker, expr,
|
||||
|
@ -408,7 +408,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
|||
|| (checker.target_version() >= PythonVersion::PY37
|
||||
&& checker.semantic.future_annotations_or_stub()
|
||||
&& checker.semantic.in_annotation()
|
||||
&& !checker.settings.pyupgrade.keep_runtime_typing)
|
||||
&& !checker.settings().pyupgrade.keep_runtime_typing)
|
||||
{
|
||||
pyupgrade::rules::use_pep585_annotation(checker, expr, &replacement);
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
|||
flake8_comprehensions::rules::unnecessary_collection_call(
|
||||
checker,
|
||||
call,
|
||||
&checker.settings.flake8_comprehensions,
|
||||
&checker.settings().flake8_comprehensions,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::UnnecessaryLiteralWithinTupleCall) {
|
||||
|
@ -1006,7 +1006,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
|||
Rule::PrintfInGetTextFuncCall,
|
||||
]) && flake8_gettext::is_gettext_func_call(
|
||||
func,
|
||||
&checker.settings.flake8_gettext.functions_names,
|
||||
&checker.settings().flake8_gettext.functions_names,
|
||||
) {
|
||||
if checker.is_rule_enabled(Rule::FStringInGetTextFuncCall) {
|
||||
flake8_gettext::rules::f_string_in_gettext_func_call(checker, args);
|
||||
|
|
|
@ -132,7 +132,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
stmt,
|
||||
name,
|
||||
decorator_list,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
&checker.semantic,
|
||||
);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
checker.semantic.current_scope(),
|
||||
stmt,
|
||||
name,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::GlobalStatement) {
|
||||
|
@ -240,7 +240,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
stmt,
|
||||
name,
|
||||
body,
|
||||
checker.settings.mccabe.max_complexity,
|
||||
checker.settings().mccabe.max_complexity,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::HardcodedPasswordDefault) {
|
||||
|
@ -265,7 +265,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
checker,
|
||||
stmt,
|
||||
body,
|
||||
checker.settings.pylint.max_returns,
|
||||
checker.settings().pylint.max_returns,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::TooManyBranches) {
|
||||
|
@ -273,7 +273,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
checker,
|
||||
stmt,
|
||||
body,
|
||||
checker.settings.pylint.max_branches,
|
||||
checker.settings().pylint.max_branches,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::TooManyStatements) {
|
||||
|
@ -281,7 +281,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
checker,
|
||||
stmt,
|
||||
body,
|
||||
checker.settings.pylint.max_statements,
|
||||
checker.settings().pylint.max_statements,
|
||||
);
|
||||
}
|
||||
if checker.any_rule_enabled(&[
|
||||
|
@ -431,7 +431,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
pylint::rules::too_many_public_methods(
|
||||
checker,
|
||||
class_def,
|
||||
checker.settings.pylint.max_public_methods,
|
||||
checker.settings().pylint.max_public_methods,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::GlobalStatement) {
|
||||
|
@ -459,7 +459,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
checker,
|
||||
stmt,
|
||||
name,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::ErrorSuffixOnExceptionName) {
|
||||
|
@ -468,7 +468,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
stmt,
|
||||
arguments.as_deref(),
|
||||
name,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if !checker.source_type.is_stub() {
|
||||
|
@ -646,7 +646,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
asname,
|
||||
alias,
|
||||
stmt,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::LowercaseImportedAsNonLowercase) {
|
||||
|
@ -656,7 +656,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
asname,
|
||||
alias,
|
||||
stmt,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::CamelcaseImportedAsLowercase) {
|
||||
|
@ -666,7 +666,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
asname,
|
||||
alias,
|
||||
stmt,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::CamelcaseImportedAsConstant) {
|
||||
|
@ -676,7 +676,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
asname,
|
||||
alias,
|
||||
stmt,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::CamelcaseImportedAsAcronym) {
|
||||
|
@ -692,7 +692,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
stmt,
|
||||
&alias.name,
|
||||
asname,
|
||||
&checker.settings.flake8_import_conventions.banned_aliases,
|
||||
&checker.settings().flake8_import_conventions.banned_aliases,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -854,7 +854,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
level,
|
||||
module,
|
||||
checker.module.qualified_name(),
|
||||
checker.settings.flake8_tidy_imports.ban_relative_imports,
|
||||
checker.settings().flake8_tidy_imports.ban_relative_imports,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::Debugger) {
|
||||
|
@ -869,7 +869,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
stmt,
|
||||
&qualified_name,
|
||||
asname,
|
||||
&checker.settings.flake8_import_conventions.banned_aliases,
|
||||
&checker.settings().flake8_import_conventions.banned_aliases,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -881,7 +881,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
asname,
|
||||
alias,
|
||||
stmt,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::LowercaseImportedAsNonLowercase) {
|
||||
|
@ -891,7 +891,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
asname,
|
||||
alias,
|
||||
stmt,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::CamelcaseImportedAsLowercase) {
|
||||
|
@ -901,7 +901,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
asname,
|
||||
alias,
|
||||
stmt,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::CamelcaseImportedAsConstant) {
|
||||
|
@ -911,7 +911,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
asname,
|
||||
alias,
|
||||
stmt,
|
||||
&checker.settings.pep8_naming.ignore_names,
|
||||
&checker.settings().pep8_naming.ignore_names,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::CamelcaseImportedAsAcronym) {
|
||||
|
@ -947,7 +947,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
|
|||
checker,
|
||||
stmt,
|
||||
&helpers::format_import_from(level, module),
|
||||
&checker.settings.flake8_import_conventions.banned_from,
|
||||
&checker.settings().flake8_import_conventions.banned_from,
|
||||
);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::ByteStringUsage) {
|
||||
|
|
|
@ -34,7 +34,7 @@ pub(crate) fn string_like(string_like: StringLike, checker: &Checker) {
|
|||
flake8_quotes::rules::unnecessary_escaped_quote(checker, string_like);
|
||||
}
|
||||
if checker.is_rule_enabled(Rule::AvoidableEscapedQuote)
|
||||
&& checker.settings.flake8_quotes.avoid_escape
|
||||
&& checker.settings().flake8_quotes.avoid_escape
|
||||
{
|
||||
flake8_quotes::rules::avoidable_escaped_quote(checker, string_like);
|
||||
}
|
||||
|
|
|
@ -207,8 +207,6 @@ pub(crate) struct Checker<'a> {
|
|||
/// The [`NoqaMapping`] for the current analysis (i.e., the mapping from line number to
|
||||
/// suppression commented line number).
|
||||
noqa_line_for: &'a NoqaMapping,
|
||||
/// The [`LinterSettings`] for the current analysis, including the enabled rules.
|
||||
pub(crate) settings: &'a LinterSettings,
|
||||
/// The [`Locator`] for the current file, which enables extraction of source code from byte
|
||||
/// offsets.
|
||||
locator: &'a Locator<'a>,
|
||||
|
@ -260,13 +258,12 @@ impl<'a> Checker<'a> {
|
|||
notebook_index: Option<&'a NotebookIndex>,
|
||||
target_version: TargetVersion,
|
||||
context: &'a LintContext<'a>,
|
||||
) -> Checker<'a> {
|
||||
) -> Self {
|
||||
let semantic = SemanticModel::new(&settings.typing_modules, path, module);
|
||||
Self {
|
||||
parsed,
|
||||
parsed_type_annotation: None,
|
||||
parsed_annotations_cache: ParsedAnnotationsCache::new(parsed_annotations_arena),
|
||||
settings,
|
||||
noqa_line_for,
|
||||
noqa,
|
||||
path,
|
||||
|
@ -464,6 +461,11 @@ impl<'a> Checker<'a> {
|
|||
&self.semantic
|
||||
}
|
||||
|
||||
/// The [`LinterSettings`] for the current analysis, including the enabled rules.
|
||||
pub(crate) const fn settings(&self) -> &'a LinterSettings {
|
||||
self.context.settings
|
||||
}
|
||||
|
||||
/// The [`Path`] to the file under analysis.
|
||||
pub(crate) const fn path(&self) -> &'a Path {
|
||||
self.path
|
||||
|
@ -576,7 +578,7 @@ impl<'a> Checker<'a> {
|
|||
) -> Option<TypingImporter<'b, 'a>> {
|
||||
let source_module = if self.target_version() >= version_added_to_typing {
|
||||
"typing"
|
||||
} else if !self.settings.typing_extensions {
|
||||
} else if !self.settings().typing_extensions {
|
||||
return None;
|
||||
} else {
|
||||
"typing_extensions"
|
||||
|
@ -1054,7 +1056,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
|
|||
let annotation = AnnotationContext::from_function(
|
||||
function_def,
|
||||
&self.semantic,
|
||||
self.settings,
|
||||
self.settings(),
|
||||
self.target_version(),
|
||||
);
|
||||
|
||||
|
@ -1256,7 +1258,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
|
|||
}) => {
|
||||
match AnnotationContext::from_model(
|
||||
&self.semantic,
|
||||
self.settings,
|
||||
self.settings(),
|
||||
self.target_version(),
|
||||
) {
|
||||
AnnotationContext::RuntimeRequired => {
|
||||
|
@ -1868,8 +1870,8 @@ impl<'a> Visitor<'a> for Checker<'a> {
|
|||
match typing::match_annotated_subscript(
|
||||
value,
|
||||
&self.semantic,
|
||||
self.settings.typing_modules.iter().map(String::as_str),
|
||||
&self.settings.pyflakes.extend_generics,
|
||||
self.settings().typing_modules.iter().map(String::as_str),
|
||||
&self.settings().pyflakes.extend_generics,
|
||||
) {
|
||||
// Ex) Literal["Class"]
|
||||
Some(typing::SubscriptKind::Literal) => {
|
||||
|
@ -2476,6 +2478,7 @@ impl<'a> Checker<'a> {
|
|||
|
||||
fn bind_builtins(&mut self) {
|
||||
let target_version = self.target_version();
|
||||
let settings = self.settings();
|
||||
let mut bind_builtin = |builtin| {
|
||||
// Add the builtin to the scope.
|
||||
let binding_id = self.semantic.push_builtin();
|
||||
|
@ -2489,7 +2492,7 @@ impl<'a> Checker<'a> {
|
|||
for builtin in MAGIC_GLOBALS {
|
||||
bind_builtin(builtin);
|
||||
}
|
||||
for builtin in &self.settings.builtins {
|
||||
for builtin in &settings.builtins {
|
||||
bind_builtin(builtin);
|
||||
}
|
||||
}
|
||||
|
@ -2963,7 +2966,7 @@ impl<'a> Checker<'a> {
|
|||
}
|
||||
} else {
|
||||
if self.is_rule_enabled(Rule::UndefinedExport) {
|
||||
if is_undefined_export_in_dunder_init_enabled(self.settings)
|
||||
if is_undefined_export_in_dunder_init_enabled(self.settings())
|
||||
|| !self.path.ends_with("__init__.py")
|
||||
{
|
||||
self.report_diagnostic(
|
||||
|
@ -3115,7 +3118,6 @@ pub(crate) struct LintContext<'a> {
|
|||
diagnostics: RefCell<Vec<OldDiagnostic>>,
|
||||
source_file: SourceFile,
|
||||
rules: RuleTable,
|
||||
#[expect(unused, reason = "TODO(brent) use this instead of Checker::settings")]
|
||||
settings: &'a LinterSettings,
|
||||
}
|
||||
|
||||
|
|
|
@ -648,9 +648,9 @@ pub(crate) fn definition(
|
|||
);
|
||||
}
|
||||
} else {
|
||||
if !(checker.settings.flake8_annotations.suppress_dummy_args
|
||||
if !(checker.settings().flake8_annotations.suppress_dummy_args
|
||||
&& checker
|
||||
.settings
|
||||
.settings()
|
||||
.dummy_variable_rgx
|
||||
.is_match(parameter.name()))
|
||||
{
|
||||
|
@ -670,15 +670,15 @@ pub(crate) fn definition(
|
|||
if let Some(arg) = ¶meters.vararg {
|
||||
if let Some(expr) = &arg.annotation {
|
||||
has_any_typed_arg = true;
|
||||
if !checker.settings.flake8_annotations.allow_star_arg_any {
|
||||
if !checker.settings().flake8_annotations.allow_star_arg_any {
|
||||
if checker.is_rule_enabled(Rule::AnyType) && !is_overridden {
|
||||
let name = &arg.name;
|
||||
check_dynamically_typed(checker, expr, || format!("*{name}"), &mut diagnostics);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if !(checker.settings.flake8_annotations.suppress_dummy_args
|
||||
&& checker.settings.dummy_variable_rgx.is_match(&arg.name))
|
||||
if !(checker.settings().flake8_annotations.suppress_dummy_args
|
||||
&& checker.settings().dummy_variable_rgx.is_match(&arg.name))
|
||||
{
|
||||
if checker.is_rule_enabled(Rule::MissingTypeArgs) {
|
||||
diagnostics.push(checker.report_diagnostic(
|
||||
|
@ -696,7 +696,7 @@ pub(crate) fn definition(
|
|||
if let Some(arg) = ¶meters.kwarg {
|
||||
if let Some(expr) = &arg.annotation {
|
||||
has_any_typed_arg = true;
|
||||
if !checker.settings.flake8_annotations.allow_star_arg_any {
|
||||
if !checker.settings().flake8_annotations.allow_star_arg_any {
|
||||
if checker.is_rule_enabled(Rule::AnyType) && !is_overridden {
|
||||
let name = &arg.name;
|
||||
check_dynamically_typed(
|
||||
|
@ -708,8 +708,8 @@ pub(crate) fn definition(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if !(checker.settings.flake8_annotations.suppress_dummy_args
|
||||
&& checker.settings.dummy_variable_rgx.is_match(&arg.name))
|
||||
if !(checker.settings().flake8_annotations.suppress_dummy_args
|
||||
&& checker.settings().dummy_variable_rgx.is_match(&arg.name))
|
||||
{
|
||||
if checker.is_rule_enabled(Rule::MissingTypeKwargs) {
|
||||
diagnostics.push(checker.report_diagnostic(
|
||||
|
@ -732,7 +732,11 @@ pub(crate) fn definition(
|
|||
} else if !(
|
||||
// Allow omission of return annotation if the function only returns `None`
|
||||
// (explicitly or implicitly).
|
||||
checker.settings.flake8_annotations.suppress_none_returning && is_none_returning(body)
|
||||
checker
|
||||
.settings()
|
||||
.flake8_annotations
|
||||
.suppress_none_returning
|
||||
&& is_none_returning(body)
|
||||
) {
|
||||
if is_method && visibility::is_classmethod(decorator_list, checker.semantic()) {
|
||||
if checker.is_rule_enabled(Rule::MissingReturnTypeClassMethod) {
|
||||
|
@ -790,7 +794,7 @@ pub(crate) fn definition(
|
|||
// Allow omission of return annotation in `__init__` functions, as long as at
|
||||
// least one argument is typed.
|
||||
if checker.is_rule_enabled(Rule::MissingReturnTypeSpecialMethod) {
|
||||
if !(checker.settings.flake8_annotations.mypy_init_return && has_any_typed_arg) {
|
||||
if !(checker.settings().flake8_annotations.mypy_init_return && has_any_typed_arg) {
|
||||
let mut diagnostic = checker.report_diagnostic(
|
||||
MissingReturnTypeSpecialMethod {
|
||||
name: name.to_string(),
|
||||
|
@ -901,7 +905,7 @@ pub(crate) fn definition(
|
|||
|
||||
// If settings say so, don't report any of the
|
||||
// diagnostics gathered here if there were no type annotations at all.
|
||||
let diagnostics_enabled = !checker.settings.flake8_annotations.ignore_fully_untyped
|
||||
let diagnostics_enabled = !checker.settings().flake8_annotations.ignore_fully_untyped
|
||||
|| has_any_typed_arg
|
||||
|| has_typed_return
|
||||
|| (is_method
|
||||
|
|
|
@ -84,7 +84,7 @@ pub(crate) fn hardcoded_tmp_directory(checker: &Checker, string: StringLike) {
|
|||
|
||||
fn check(checker: &Checker, value: &str, range: TextRange) {
|
||||
if !checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_bandit
|
||||
.hardcoded_tmp_directory
|
||||
.iter()
|
||||
|
|
|
@ -936,7 +936,7 @@ pub(crate) fn suspicious_function_call(checker: &Checker, call: &ExprCall) {
|
|||
}
|
||||
|
||||
pub(crate) fn suspicious_function_reference(checker: &Checker, func: &Expr) {
|
||||
if !is_suspicious_function_reference_enabled(checker.settings) {
|
||||
if !is_suspicious_function_reference_enabled(checker.settings()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1270,7 +1270,7 @@ fn suspicious_function(
|
|||
/// S308
|
||||
pub(crate) fn suspicious_function_decorator(checker: &Checker, decorator: &Decorator) {
|
||||
// In preview mode, references are handled collectively by `suspicious_function_reference`
|
||||
if !is_suspicious_function_reference_enabled(checker.settings) {
|
||||
if !is_suspicious_function_reference_enabled(checker.settings()) {
|
||||
suspicious_function(checker, &decorator.expression, None, decorator.range);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ impl Violation for UnsafeMarkupUse {
|
|||
/// S704
|
||||
pub(crate) fn unsafe_markup_call(checker: &Checker, call: &ExprCall) {
|
||||
if checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_bandit
|
||||
.extend_markup_names
|
||||
.is_empty()
|
||||
|
@ -100,7 +100,7 @@ pub(crate) fn unsafe_markup_call(checker: &Checker, call: &ExprCall) {
|
|||
return;
|
||||
}
|
||||
|
||||
if !is_unsafe_call(call, checker.semantic(), checker.settings) {
|
||||
if !is_unsafe_call(call, checker.semantic(), checker.settings()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ pub(crate) fn unsafe_markup_call(checker: &Checker, call: &ExprCall) {
|
|||
return;
|
||||
};
|
||||
|
||||
if !is_markup_call(&qualified_name, checker.settings) {
|
||||
if !is_markup_call(&qualified_name, checker.settings()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ pub(crate) fn blind_except(
|
|||
}
|
||||
|
||||
// If the exception is logged, don't flag an error.
|
||||
let mut visitor = LogExceptionVisitor::new(semantic, &checker.settings.logger_objects);
|
||||
let mut visitor = LogExceptionVisitor::new(semantic, &checker.settings().logger_objects);
|
||||
visitor.visit_body(body);
|
||||
if visitor.seen() {
|
||||
return;
|
||||
|
|
|
@ -185,7 +185,7 @@ pub(super) fn allow_boolean_trap(call: &ast::ExprCall, checker: &Checker) -> boo
|
|||
}
|
||||
|
||||
// If the call is explicitly allowed by the user, then the boolean trap is allowed.
|
||||
if is_user_allowed_func_call(call, checker.semantic(), checker.settings) {
|
||||
if is_user_allowed_func_call(call, checker.semantic(), checker.settings()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,8 +88,8 @@ pub(crate) fn cached_instance_method(checker: &Checker, function_def: &ast::Stmt
|
|||
&function_def.decorator_list,
|
||||
scope,
|
||||
checker.semantic(),
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
);
|
||||
if !matches!(type_, function_type::FunctionType::Method) {
|
||||
return;
|
||||
|
|
|
@ -132,7 +132,7 @@ impl Visitor<'_> for ArgumentDefaultVisitor<'_, '_> {
|
|||
pub(crate) fn function_call_in_argument_default(checker: &Checker, parameters: &Parameters) {
|
||||
// Map immutable calls to (module, member) format.
|
||||
let extend_immutable_calls: Vec<QualifiedName> = checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_bugbear
|
||||
.extend_immutable_calls
|
||||
.iter()
|
||||
|
|
|
@ -105,7 +105,7 @@ pub(crate) fn mutable_argument_default(checker: &Checker, function_def: &ast::St
|
|||
};
|
||||
|
||||
let extend_immutable_calls: Vec<QualifiedName> = checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_bugbear
|
||||
.extend_immutable_calls
|
||||
.iter()
|
||||
|
|
|
@ -82,7 +82,7 @@ pub(crate) fn mutable_contextvar_default(checker: &Checker, call: &ast::ExprCall
|
|||
};
|
||||
|
||||
let extend_immutable_calls: Vec<QualifiedName> = checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_bugbear
|
||||
.extend_immutable_calls
|
||||
.iter()
|
||||
|
|
|
@ -93,7 +93,7 @@ pub(crate) fn unused_loop_control_variable(checker: &Checker, stmt_for: &ast::St
|
|||
|
||||
for (name, expr) in control_names {
|
||||
// Ignore names that are already underscore-prefixed.
|
||||
if checker.settings.dummy_variable_rgx.is_match(name) {
|
||||
if checker.settings().dummy_variable_rgx.is_match(name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ pub(crate) fn unused_loop_control_variable(checker: &Checker, stmt_for: &ast::St
|
|||
// violation in the next pass.
|
||||
let rename = format!("_{name}");
|
||||
let rename = checker
|
||||
.settings
|
||||
.settings()
|
||||
.dummy_variable_rgx
|
||||
.is_match(rename.as_str())
|
||||
.then_some(rename);
|
||||
|
|
|
@ -66,7 +66,7 @@ pub(crate) fn builtin_argument_shadowing(checker: &Checker, parameter: &Paramete
|
|||
if shadows_builtin(
|
||||
parameter.name(),
|
||||
checker.source_type,
|
||||
&checker.settings.flake8_builtins.ignorelist,
|
||||
&checker.settings().flake8_builtins.ignorelist,
|
||||
checker.target_version(),
|
||||
) {
|
||||
// Ignore parameters in lambda expressions.
|
||||
|
|
|
@ -97,7 +97,7 @@ pub(crate) fn builtin_attribute_shadowing(
|
|||
if shadows_builtin(
|
||||
name,
|
||||
checker.source_type,
|
||||
&checker.settings.flake8_builtins.ignorelist,
|
||||
&checker.settings().flake8_builtins.ignorelist,
|
||||
checker.target_version(),
|
||||
) {
|
||||
// Ignore explicit overrides.
|
||||
|
|
|
@ -59,7 +59,7 @@ pub(crate) fn builtin_import_shadowing(checker: &Checker, alias: &Alias) {
|
|||
if shadows_builtin(
|
||||
name.as_str(),
|
||||
checker.source_type,
|
||||
&checker.settings.flake8_builtins.ignorelist,
|
||||
&checker.settings().flake8_builtins.ignorelist,
|
||||
checker.target_version(),
|
||||
) {
|
||||
checker.report_diagnostic(
|
||||
|
|
|
@ -43,7 +43,7 @@ pub(crate) fn builtin_lambda_argument_shadowing(checker: &Checker, lambda: &Expr
|
|||
if shadows_builtin(
|
||||
name,
|
||||
checker.source_type,
|
||||
&checker.settings.flake8_builtins.ignorelist,
|
||||
&checker.settings().flake8_builtins.ignorelist,
|
||||
checker.target_version(),
|
||||
) {
|
||||
checker.report_diagnostic(
|
||||
|
|
|
@ -70,7 +70,7 @@ pub(crate) fn builtin_variable_shadowing(checker: &Checker, name: &str, range: T
|
|||
if shadows_builtin(
|
||||
name,
|
||||
checker.source_type,
|
||||
&checker.settings.flake8_builtins.ignorelist,
|
||||
&checker.settings().flake8_builtins.ignorelist,
|
||||
checker.target_version(),
|
||||
) {
|
||||
checker.report_diagnostic(
|
||||
|
|
|
@ -126,7 +126,7 @@ pub(crate) fn unnecessary_comprehension_in_call(
|
|||
if !(matches!(
|
||||
builtin_function,
|
||||
SupportedBuiltins::Any | SupportedBuiltins::All
|
||||
) || (is_comprehension_with_min_max_sum_enabled(checker.settings)
|
||||
) || (is_comprehension_with_min_max_sum_enabled(checker.settings())
|
||||
&& matches!(
|
||||
builtin_function,
|
||||
SupportedBuiltins::Sum | SupportedBuiltins::Min | SupportedBuiltins::Max
|
||||
|
|
|
@ -101,7 +101,7 @@ pub(crate) fn unnecessary_literal_within_tuple_call(
|
|||
let argument_kind = match argument {
|
||||
Expr::Tuple(_) => TupleLiteralKind::Tuple,
|
||||
Expr::List(_) => TupleLiteralKind::List,
|
||||
Expr::ListComp(_) if is_check_comprehensions_in_tuple_call_enabled(checker.settings) => {
|
||||
Expr::ListComp(_) if is_check_comprehensions_in_tuple_call_enabled(checker.settings()) => {
|
||||
TupleLiteralKind::ListComp
|
||||
}
|
||||
_ => return,
|
||||
|
|
|
@ -186,7 +186,7 @@ pub(crate) fn string_in_exception(checker: &Checker, stmt: &Stmt, exc: &Expr) {
|
|||
// Check for string literals.
|
||||
Expr::StringLiteral(ast::ExprStringLiteral { value: string, .. }) => {
|
||||
if checker.is_rule_enabled(Rule::RawStringInException) {
|
||||
if string.len() >= checker.settings.flake8_errmsg.max_string_length {
|
||||
if string.len() >= checker.settings().flake8_errmsg.max_string_length {
|
||||
let mut diagnostic =
|
||||
checker.report_diagnostic(RawStringInException, first.range());
|
||||
if let Some(indentation) =
|
||||
|
|
|
@ -52,7 +52,11 @@ pub(crate) fn explicit(checker: &Checker, expr: &Expr) {
|
|||
// strings that span multiple lines even if this rule is enabled. Otherwise, there's no way
|
||||
// for the user to write multiline strings, and that setting is "more explicit" than this rule
|
||||
// being enabled.
|
||||
if !checker.settings.flake8_implicit_str_concat.allow_multiline {
|
||||
if !checker
|
||||
.settings()
|
||||
.flake8_implicit_str_concat
|
||||
.allow_multiline
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ pub(crate) fn exc_info_outside_except_handler(checker: &Checker, call: &ExprCall
|
|||
|
||||
match &*call.func {
|
||||
func @ Expr::Attribute(ExprAttribute { attr, .. }) => {
|
||||
if !is_logger_candidate(func, semantic, &checker.settings.logger_objects) {
|
||||
if !is_logger_candidate(func, semantic, &checker.settings().logger_objects) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ pub(crate) fn exception_without_exc_info(checker: &Checker, call: &ExprCall) {
|
|||
if !logging::is_logger_candidate(
|
||||
&call.func,
|
||||
checker.semantic(),
|
||||
&checker.settings.logger_objects,
|
||||
&checker.settings().logger_objects,
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ pub(crate) fn log_exception_outside_except_handler(checker: &Checker, call: &Exp
|
|||
|
||||
let fix = match &*call.func {
|
||||
func @ Expr::Attribute(ExprAttribute { attr, .. }) => {
|
||||
let logger_objects = &checker.settings.logger_objects;
|
||||
let logger_objects = &checker.settings().logger_objects;
|
||||
|
||||
if !logging::is_logger_candidate(func, semantic, logger_objects) {
|
||||
return;
|
||||
|
|
|
@ -147,7 +147,7 @@ pub(crate) fn logging_call(checker: &Checker, call: &ast::ExprCall) {
|
|||
if !logging::is_logger_candidate(
|
||||
&call.func,
|
||||
checker.semantic(),
|
||||
&checker.settings.logger_objects,
|
||||
&checker.settings().logger_objects,
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ pub(crate) fn bad_version_info_comparison(checker: &Checker, test: &Expr, has_el
|
|||
if matches!(op, CmpOp::Lt) {
|
||||
if checker.is_rule_enabled(Rule::BadVersionInfoOrder)
|
||||
// See https://github.com/astral-sh/ruff/issues/15347
|
||||
&& (checker.source_type.is_stub() || is_bad_version_info_in_non_stub_enabled(checker.settings))
|
||||
&& (checker.source_type.is_stub() || is_bad_version_info_in_non_stub_enabled(checker.settings()))
|
||||
{
|
||||
if has_else_clause {
|
||||
checker.report_diagnostic(BadVersionInfoOrder, test.range());
|
||||
|
|
|
@ -173,8 +173,8 @@ pub(crate) fn custom_type_var_instead_of_self(checker: &Checker, binding: &Bindi
|
|||
decorator_list,
|
||||
current_scope,
|
||||
semantic,
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
);
|
||||
|
||||
let method = match function_kind {
|
||||
|
|
|
@ -75,8 +75,8 @@ pub(crate) fn pep_484_positional_parameter(checker: &Checker, function_def: &ast
|
|||
&function_def.decorator_list,
|
||||
scope,
|
||||
semantic,
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
);
|
||||
|
||||
// If the method has a `self` or `cls` argument, skip it.
|
||||
|
|
|
@ -714,7 +714,7 @@ fn check_fixture_decorator(checker: &Checker, func_name: &str, decorator: &Decor
|
|||
node_index: _,
|
||||
}) => {
|
||||
if checker.is_rule_enabled(Rule::PytestFixtureIncorrectParenthesesStyle) {
|
||||
if !checker.settings.flake8_pytest_style.fixture_parentheses
|
||||
if !checker.settings().flake8_pytest_style.fixture_parentheses
|
||||
&& arguments.args.is_empty()
|
||||
&& arguments.keywords.is_empty()
|
||||
{
|
||||
|
@ -771,7 +771,7 @@ fn check_fixture_decorator(checker: &Checker, func_name: &str, decorator: &Decor
|
|||
}
|
||||
_ => {
|
||||
if checker.is_rule_enabled(Rule::PytestFixtureIncorrectParenthesesStyle) {
|
||||
if checker.settings.flake8_pytest_style.fixture_parentheses {
|
||||
if checker.settings().flake8_pytest_style.fixture_parentheses {
|
||||
let fix = Fix::safe_edit(Edit::insertion(
|
||||
Parentheses::Empty.to_string(),
|
||||
decorator.end(),
|
||||
|
|
|
@ -165,7 +165,7 @@ fn check_mark_parentheses(checker: &Checker, decorator: &Decorator, marker: &str
|
|||
range: _,
|
||||
node_index: _,
|
||||
}) => {
|
||||
if !checker.settings.flake8_pytest_style.mark_parentheses
|
||||
if !checker.settings().flake8_pytest_style.mark_parentheses
|
||||
&& args.is_empty()
|
||||
&& keywords.is_empty()
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ fn check_mark_parentheses(checker: &Checker, decorator: &Decorator, marker: &str
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
if checker.settings.flake8_pytest_style.mark_parentheses {
|
||||
if checker.settings().flake8_pytest_style.mark_parentheses {
|
||||
let fix = Fix::safe_edit(Edit::insertion(
|
||||
Parentheses::Empty.to_string(),
|
||||
decorator.end(),
|
||||
|
|
|
@ -335,7 +335,10 @@ fn get_parametrize_name_range(
|
|||
|
||||
/// PT006
|
||||
fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr) {
|
||||
let names_type = checker.settings.flake8_pytest_style.parametrize_names_type;
|
||||
let names_type = checker
|
||||
.settings()
|
||||
.flake8_pytest_style
|
||||
.parametrize_names_type;
|
||||
|
||||
match expr {
|
||||
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
|
||||
|
@ -516,10 +519,13 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr
|
|||
|
||||
/// PT007
|
||||
fn check_values(checker: &Checker, names: &Expr, values: &Expr) {
|
||||
let values_type = checker.settings.flake8_pytest_style.parametrize_values_type;
|
||||
let values_type = checker
|
||||
.settings()
|
||||
.flake8_pytest_style
|
||||
.parametrize_values_type;
|
||||
|
||||
let values_row_type = checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_pytest_style
|
||||
.parametrize_values_row_type;
|
||||
|
||||
|
|
|
@ -244,13 +244,13 @@ fn exception_needs_match(checker: &Checker, exception: &Expr) {
|
|||
.and_then(|qualified_name| {
|
||||
let qualified_name = qualified_name.to_string();
|
||||
checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_pytest_style
|
||||
.raises_require_match_for
|
||||
.iter()
|
||||
.chain(
|
||||
&checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_pytest_style
|
||||
.raises_extend_require_match_for,
|
||||
)
|
||||
|
|
|
@ -233,13 +233,13 @@ fn warning_needs_match(checker: &Checker, warning: &Expr) {
|
|||
.and_then(|qualified_name| {
|
||||
let qualified_name = qualified_name.to_string();
|
||||
checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_pytest_style
|
||||
.warns_require_match_for
|
||||
.iter()
|
||||
.chain(
|
||||
&checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_pytest_style
|
||||
.warns_extend_require_match_for,
|
||||
)
|
||||
|
|
|
@ -86,7 +86,7 @@ impl<'a, 'b> AvoidableEscapedQuoteChecker<'a, 'b> {
|
|||
fn new(checker: &'a Checker<'b>, target_version: PythonVersion) -> Self {
|
||||
Self {
|
||||
checker,
|
||||
quotes_settings: &checker.settings.flake8_quotes,
|
||||
quotes_settings: &checker.settings().flake8_quotes,
|
||||
supports_pep701: target_version.supports_pep_701(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ fn text_ends_at_quote(locator: &Locator, range: TextRange, quote: Quote) -> bool
|
|||
|
||||
/// Q002
|
||||
fn docstring(checker: &Checker, range: TextRange) {
|
||||
let quotes_settings = &checker.settings.flake8_quotes;
|
||||
let quotes_settings = &checker.settings().flake8_quotes;
|
||||
let locator = checker.locator();
|
||||
|
||||
let text = locator.slice(range);
|
||||
|
@ -302,7 +302,7 @@ fn docstring(checker: &Checker, range: TextRange) {
|
|||
|
||||
/// Q000, Q001
|
||||
fn strings(checker: &Checker, sequence: &[TextRange]) {
|
||||
let quotes_settings = &checker.settings.flake8_quotes;
|
||||
let quotes_settings = &checker.settings().flake8_quotes;
|
||||
let locator = checker.locator();
|
||||
|
||||
let trivia = sequence
|
||||
|
|
|
@ -379,7 +379,7 @@ fn unnecessary_return_none(checker: &Checker, decorator_list: &[Decorator], stac
|
|||
// Skip property functions
|
||||
if is_property(
|
||||
decorator_list,
|
||||
checker.settings.pydocstyle.property_decorators(),
|
||||
checker.settings().pydocstyle.property_decorators(),
|
||||
checker.semantic(),
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -85,7 +85,7 @@ pub(crate) fn private_member_access(checker: &Checker, expr: &Expr) {
|
|||
}
|
||||
|
||||
if checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_self
|
||||
.ignore_names
|
||||
.contains(attr.id())
|
||||
|
|
|
@ -191,11 +191,11 @@ pub(crate) fn multiple_with_statements(
|
|||
content,
|
||||
with_stmt.into(),
|
||||
checker.locator(),
|
||||
checker.settings.pycodestyle.max_line_length,
|
||||
checker.settings.tab_size,
|
||||
checker.settings().pycodestyle.max_line_length,
|
||||
checker.settings().tab_size,
|
||||
)
|
||||
}) {
|
||||
if is_multiple_with_statements_fix_safe_enabled(checker.settings) {
|
||||
if is_multiple_with_statements_fix_safe_enabled(checker.settings()) {
|
||||
Ok(Some(Fix::safe_edit(edit)))
|
||||
} else {
|
||||
Ok(Some(Fix::unsafe_edit(edit)))
|
||||
|
|
|
@ -125,8 +125,8 @@ pub(crate) fn nested_if_statements(
|
|||
content,
|
||||
(&nested_if).into(),
|
||||
checker.locator(),
|
||||
checker.settings.pycodestyle.max_line_length,
|
||||
checker.settings.tab_size,
|
||||
checker.settings().pycodestyle.max_line_length,
|
||||
checker.settings().tab_size,
|
||||
)
|
||||
}) {
|
||||
Ok(Some(Fix::unsafe_edit(edit)))
|
||||
|
|
|
@ -215,8 +215,8 @@ pub(crate) fn if_else_block_instead_of_dict_get(checker: &Checker, stmt_if: &ast
|
|||
&contents,
|
||||
stmt_if.into(),
|
||||
checker.locator(),
|
||||
checker.settings.pycodestyle.max_line_length,
|
||||
checker.settings.tab_size,
|
||||
checker.settings().pycodestyle.max_line_length,
|
||||
checker.settings().tab_size,
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -225,8 +225,8 @@ pub(crate) fn if_else_block_instead_of_if_exp(checker: &Checker, stmt_if: &ast::
|
|||
&contents,
|
||||
stmt_if.into(),
|
||||
checker.locator(),
|
||||
checker.settings.pycodestyle.max_line_length,
|
||||
checker.settings.tab_size,
|
||||
checker.settings().pycodestyle.max_line_length,
|
||||
checker.settings().tab_size,
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -105,8 +105,8 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) {
|
|||
&contents,
|
||||
stmt.into(),
|
||||
checker.locator(),
|
||||
checker.settings.pycodestyle.max_line_length,
|
||||
checker.settings.tab_size,
|
||||
checker.settings().pycodestyle.max_line_length,
|
||||
checker.settings().tab_size,
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
@ -195,14 +195,14 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) {
|
|||
|
||||
// Don't flag if the resulting expression would exceed the maximum line length.
|
||||
let line_start = checker.locator().line_start(stmt.start());
|
||||
if LineWidthBuilder::new(checker.settings.tab_size)
|
||||
if LineWidthBuilder::new(checker.settings().tab_size)
|
||||
.add_str(
|
||||
checker
|
||||
.locator()
|
||||
.slice(TextRange::new(line_start, stmt.start())),
|
||||
)
|
||||
.add_str(&contents)
|
||||
> checker.settings.pycodestyle.max_line_length
|
||||
> checker.settings().pycodestyle.max_line_length
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ impl Violation for BannedApi {
|
|||
|
||||
/// TID251
|
||||
pub(crate) fn banned_api<T: Ranged>(checker: &Checker, policy: &NameMatchPolicy, node: &T) {
|
||||
let banned_api = &checker.settings.flake8_tidy_imports.banned_api;
|
||||
let banned_api = &checker.settings().flake8_tidy_imports.banned_api;
|
||||
if let Some(banned_module) = policy.find(banned_api.keys().map(AsRef::as_ref)) {
|
||||
if let Some(reason) = banned_api.get(&banned_module) {
|
||||
checker.report_diagnostic(
|
||||
|
@ -56,7 +56,7 @@ pub(crate) fn banned_api<T: Ranged>(checker: &Checker, policy: &NameMatchPolicy,
|
|||
|
||||
/// TID251
|
||||
pub(crate) fn banned_attribute_access(checker: &Checker, expr: &Expr) {
|
||||
let banned_api = &checker.settings.flake8_tidy_imports.banned_api;
|
||||
let banned_api = &checker.settings().flake8_tidy_imports.banned_api;
|
||||
if banned_api.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ pub(crate) fn banned_module_level_imports(checker: &Checker, stmt: &Stmt) {
|
|||
for (policy, node) in &BannedModuleImportPolicies::new(stmt, checker) {
|
||||
if let Some(banned_module) = policy.find(
|
||||
checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_tidy_imports
|
||||
.banned_module_level_imports(),
|
||||
) {
|
||||
|
|
|
@ -164,7 +164,7 @@ pub(crate) fn runtime_import_in_type_checking_block(checker: &Checker, scope: &S
|
|||
// since some people will consistently use their
|
||||
// type aliases at runtimes, while others won't, so
|
||||
// the best solution is unclear.
|
||||
if checker.settings.flake8_type_checking.quote_annotations
|
||||
if checker.settings().flake8_type_checking.quote_annotations
|
||||
&& binding.references().all(|reference_id| {
|
||||
let reference = checker.semantic().reference(reference_id);
|
||||
reference.in_typing_context() || reference.in_runtime_evaluated_annotation()
|
||||
|
|
|
@ -273,7 +273,7 @@ pub(crate) fn typing_only_runtime_import(
|
|||
|
||||
// If we're in un-strict mode, don't flag typing-only imports that are
|
||||
// implicitly loaded by way of a valid runtime import.
|
||||
if !checker.settings.flake8_type_checking.strict
|
||||
if !checker.settings().flake8_type_checking.strict
|
||||
&& runtime_imports
|
||||
.iter()
|
||||
.any(|import| is_implicit_import(binding, import))
|
||||
|
@ -294,7 +294,7 @@ pub(crate) fn typing_only_runtime_import(
|
|||
.references()
|
||||
.map(|reference_id| checker.semantic().reference(reference_id))
|
||||
.all(|reference| {
|
||||
is_typing_reference(reference, &checker.settings.flake8_type_checking)
|
||||
is_typing_reference(reference, &checker.settings().flake8_type_checking)
|
||||
})
|
||||
{
|
||||
let qualified_name = import.qualified_name();
|
||||
|
@ -302,7 +302,7 @@ pub(crate) fn typing_only_runtime_import(
|
|||
if is_exempt(
|
||||
&qualified_name.to_string(),
|
||||
&checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_type_checking
|
||||
.exempt_modules
|
||||
.iter()
|
||||
|
@ -316,7 +316,7 @@ pub(crate) fn typing_only_runtime_import(
|
|||
|
||||
// Categorize the import, using coarse-grained categorization.
|
||||
let match_source_strategy =
|
||||
if is_full_path_match_source_strategy_enabled(checker.settings) {
|
||||
if is_full_path_match_source_strategy_enabled(checker.settings()) {
|
||||
MatchSourceStrategy::FullPath
|
||||
} else {
|
||||
MatchSourceStrategy::Root
|
||||
|
@ -325,14 +325,14 @@ pub(crate) fn typing_only_runtime_import(
|
|||
let import_type = match categorize(
|
||||
&source_name,
|
||||
qualified_name.is_unresolved_import(),
|
||||
&checker.settings.src,
|
||||
&checker.settings().src,
|
||||
checker.package(),
|
||||
checker.settings.isort.detect_same_package,
|
||||
&checker.settings.isort.known_modules,
|
||||
checker.settings().isort.detect_same_package,
|
||||
&checker.settings().isort.known_modules,
|
||||
checker.target_version(),
|
||||
checker.settings.isort.no_sections,
|
||||
&checker.settings.isort.section_order,
|
||||
&checker.settings.isort.default_section,
|
||||
checker.settings().isort.no_sections,
|
||||
&checker.settings().isort.section_order,
|
||||
&checker.settings().isort.default_section,
|
||||
match_source_strategy,
|
||||
) {
|
||||
ImportSection::Known(ImportType::LocalFolder | ImportType::FirstParty) => {
|
||||
|
|
|
@ -250,7 +250,7 @@ impl Argumentable {
|
|||
/// Check a plain function for unused arguments.
|
||||
fn function(argumentable: Argumentable, parameters: &Parameters, scope: &Scope, checker: &Checker) {
|
||||
let ignore_variadic_names = checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_unused_arguments
|
||||
.ignore_variadic_names;
|
||||
let args = parameters
|
||||
|
@ -276,7 +276,7 @@ fn function(argumentable: Argumentable, parameters: &Parameters, scope: &Scope,
|
|||
/// Check a method for unused arguments.
|
||||
fn method(argumentable: Argumentable, parameters: &Parameters, scope: &Scope, checker: &Checker) {
|
||||
let ignore_variadic_names = checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_unused_arguments
|
||||
.ignore_variadic_names;
|
||||
let args = parameters
|
||||
|
@ -307,7 +307,7 @@ fn call<'a>(
|
|||
checker: &Checker,
|
||||
) {
|
||||
let semantic = checker.semantic();
|
||||
let dummy_variable_rgx = &checker.settings.dummy_variable_rgx;
|
||||
let dummy_variable_rgx = &checker.settings().dummy_variable_rgx;
|
||||
for arg in parameters {
|
||||
let Some(binding) = scope
|
||||
.get(arg.name())
|
||||
|
@ -408,8 +408,8 @@ pub(crate) fn unused_arguments(checker: &Checker, scope: &Scope) {
|
|||
decorator_list,
|
||||
parent,
|
||||
checker.semantic(),
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
) {
|
||||
function_type::FunctionType::Function => {
|
||||
if checker.is_rule_enabled(Argumentable::Function.rule_code())
|
||||
|
|
|
@ -68,7 +68,7 @@ pub(crate) fn camelcase_imported_as_acronym(
|
|||
&& str::is_cased_uppercase(asname)
|
||||
&& helpers::is_acronym(name, asname)
|
||||
{
|
||||
let ignore_names = &checker.settings.pep8_naming.ignore_names;
|
||||
let ignore_names = &checker.settings().pep8_naming.ignore_names;
|
||||
|
||||
// Ignore any explicitly-allowed names.
|
||||
if ignore_names.matches(name) || ignore_names.matches(asname) {
|
||||
|
@ -114,7 +114,7 @@ fn is_ignored_because_of_import_convention(
|
|||
|
||||
// Ignore names that follow a community-agreed import convention.
|
||||
checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_import_conventions
|
||||
.aliases
|
||||
.get(&*full_name)
|
||||
|
|
|
@ -81,7 +81,7 @@ pub(crate) fn invalid_argument_name_lambda(checker: &Checker, lambda: &ExprLambd
|
|||
|
||||
/// N803
|
||||
fn invalid_argument_name(checker: &Checker, parameters: &Parameters) {
|
||||
let ignore_names = &checker.settings.pep8_naming.ignore_names;
|
||||
let ignore_names = &checker.settings().pep8_naming.ignore_names;
|
||||
|
||||
for parameter in parameters {
|
||||
let name = parameter.name().as_str();
|
||||
|
|
|
@ -226,8 +226,8 @@ pub(crate) fn invalid_first_argument_name(checker: &Checker, scope: &Scope) {
|
|||
decorator_list,
|
||||
parent_scope,
|
||||
semantic,
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
) {
|
||||
function_type::FunctionType::Function | function_type::FunctionType::StaticMethod => {
|
||||
return;
|
||||
|
@ -260,7 +260,7 @@ pub(crate) fn invalid_first_argument_name(checker: &Checker, scope: &Scope) {
|
|||
|
||||
if &self_or_cls.name == function_type.valid_first_argument_name()
|
||||
|| checker
|
||||
.settings
|
||||
.settings()
|
||||
.pep8_naming
|
||||
.ignore_names
|
||||
.matches(&self_or_cls.name)
|
||||
|
|
|
@ -72,7 +72,7 @@ pub(crate) fn mixed_case_variable_in_class_scope(
|
|||
return;
|
||||
}
|
||||
|
||||
if checker.settings.pep8_naming.ignore_names.matches(name) {
|
||||
if checker.settings().pep8_naming.ignore_names.matches(name) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ pub(crate) fn mixed_case_variable_in_global_scope(checker: &Checker, expr: &Expr
|
|||
return;
|
||||
}
|
||||
|
||||
if checker.settings.pep8_naming.ignore_names.matches(name) {
|
||||
if checker.settings().pep8_naming.ignore_names.matches(name) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ pub(crate) fn non_lowercase_variable_in_function(checker: &Checker, expr: &Expr,
|
|||
}
|
||||
|
||||
// Ignore explicitly-allowed names.
|
||||
if checker.settings.pep8_naming.ignore_names.matches(name) {
|
||||
if checker.settings().pep8_naming.ignore_names.matches(name) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ pub(crate) fn manual_dict_comprehension(checker: &Checker, for_stmt: &ast::StmtF
|
|||
return;
|
||||
}
|
||||
|
||||
if is_fix_manual_dict_comprehension_enabled(checker.settings) {
|
||||
if is_fix_manual_dict_comprehension_enabled(checker.settings()) {
|
||||
let binding_stmt = binding.statement(checker.semantic());
|
||||
let binding_value = binding_stmt.and_then(|binding_stmt| match binding_stmt {
|
||||
ast::Stmt::AnnAssign(assign) => assign.value.as_deref(),
|
||||
|
|
|
@ -337,7 +337,7 @@ pub(crate) fn manual_list_comprehension(checker: &Checker, for_stmt: &ast::StmtF
|
|||
);
|
||||
|
||||
// TODO: once this fix is stabilized, change the rule to always fixable
|
||||
if is_fix_manual_list_comprehension_enabled(checker.settings) {
|
||||
if is_fix_manual_list_comprehension_enabled(checker.settings()) {
|
||||
diagnostic.try_set_fix(|| {
|
||||
convert_to_list_extend(
|
||||
comprehension_type,
|
||||
|
|
|
@ -887,7 +887,7 @@ pub(crate) fn check_docstring(
|
|||
return;
|
||||
};
|
||||
|
||||
if checker.settings.pydoclint.ignore_one_line_docstrings && is_one_line(docstring) {
|
||||
if checker.settings().pydoclint.ignore_one_line_docstrings && is_one_line(docstring) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -919,7 +919,7 @@ pub(crate) fn check_docstring(
|
|||
if should_document_returns(function_def)
|
||||
&& !returns_documented(docstring, &docstring_sections, convention)
|
||||
{
|
||||
let extra_property_decorators = checker.settings.pydocstyle.property_decorators();
|
||||
let extra_property_decorators = checker.settings().pydocstyle.property_decorators();
|
||||
if !definition.is_property(extra_property_decorators, semantic) {
|
||||
if !body_entries.returns.is_empty() {
|
||||
match function_def.returns.as_deref() {
|
||||
|
|
|
@ -1789,7 +1789,7 @@ fn missing_args(checker: &Checker, docstring: &Docstring, docstrings_args: &FxHa
|
|||
|
||||
// Check specifically for `vararg` and `kwarg`, which can be prefixed with a
|
||||
// single or double star, respectively.
|
||||
if !checker.settings.pydocstyle.ignore_var_parameters() {
|
||||
if !checker.settings().pydocstyle.ignore_var_parameters() {
|
||||
if let Some(arg) = function.parameters.vararg.as_ref() {
|
||||
let arg_name = arg.name.as_str();
|
||||
let starred_arg_name = format!("*{arg_name}");
|
||||
|
|
|
@ -39,7 +39,7 @@ pub(crate) fn unused_annotation(checker: &Checker, scope: &Scope) {
|
|||
let binding = checker.semantic().binding(binding_id);
|
||||
if binding.kind.is_annotation()
|
||||
&& binding.is_unused()
|
||||
&& !checker.settings.dummy_variable_rgx.is_match(name)
|
||||
&& !checker.settings().dummy_variable_rgx.is_match(name)
|
||||
{
|
||||
Some((name.to_string(), binding.range()))
|
||||
} else {
|
||||
|
|
|
@ -231,7 +231,7 @@ enum UnusedImportContext {
|
|||
|
||||
fn is_first_party(import: &AnyImport, checker: &Checker) -> bool {
|
||||
let source_name = import.source_name().join(".");
|
||||
let match_source_strategy = if is_full_path_match_source_strategy_enabled(checker.settings) {
|
||||
let match_source_strategy = if is_full_path_match_source_strategy_enabled(checker.settings()) {
|
||||
MatchSourceStrategy::FullPath
|
||||
} else {
|
||||
MatchSourceStrategy::Root
|
||||
|
@ -239,14 +239,14 @@ fn is_first_party(import: &AnyImport, checker: &Checker) -> bool {
|
|||
let category = isort::categorize(
|
||||
&source_name,
|
||||
import.qualified_name().is_unresolved_import(),
|
||||
&checker.settings.src,
|
||||
&checker.settings().src,
|
||||
checker.package(),
|
||||
checker.settings.isort.detect_same_package,
|
||||
&checker.settings.isort.known_modules,
|
||||
checker.settings().isort.detect_same_package,
|
||||
&checker.settings().isort.known_modules,
|
||||
checker.target_version(),
|
||||
checker.settings.isort.no_sections,
|
||||
&checker.settings.isort.section_order,
|
||||
&checker.settings.isort.default_section,
|
||||
checker.settings().isort.no_sections,
|
||||
&checker.settings().isort.section_order,
|
||||
&checker.settings().isort.default_section,
|
||||
match_source_strategy,
|
||||
);
|
||||
matches! {
|
||||
|
@ -317,7 +317,7 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope) {
|
|||
// If an import is marked as required, avoid treating it as unused, regardless of whether
|
||||
// it was _actually_ used.
|
||||
if checker
|
||||
.settings
|
||||
.settings()
|
||||
.isort
|
||||
.required_imports
|
||||
.iter()
|
||||
|
@ -328,7 +328,7 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope) {
|
|||
|
||||
// If an import was marked as allowed, avoid treating it as unused.
|
||||
if checker
|
||||
.settings
|
||||
.settings()
|
||||
.pyflakes
|
||||
.allowed_unused_imports
|
||||
.iter()
|
||||
|
@ -366,8 +366,8 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope) {
|
|||
}
|
||||
|
||||
let in_init = checker.path().ends_with("__init__.py");
|
||||
let fix_init = !checker.settings.ignore_init_module_imports;
|
||||
let preview_mode = is_dunder_init_fix_unused_import_enabled(checker.settings);
|
||||
let fix_init = !checker.settings().ignore_init_module_imports;
|
||||
let preview_mode = is_dunder_init_fix_unused_import_enabled(checker.settings());
|
||||
let dunder_all_exprs = find_dunder_all_exprs(checker.semantic());
|
||||
|
||||
// Generate a diagnostic for every import, but share fixes across all imports within the same
|
||||
|
|
|
@ -187,7 +187,7 @@ fn remove_unused_variable(binding: &Binding, checker: &Checker) -> Option<Fix> {
|
|||
} else {
|
||||
let name = binding.name(checker.source());
|
||||
let renamed = format!("_{name}");
|
||||
if checker.settings.dummy_variable_rgx.is_match(&renamed) {
|
||||
if checker.settings().dummy_variable_rgx.is_match(&renamed) {
|
||||
let edit = Edit::range_replacement(renamed, binding.range());
|
||||
|
||||
return Some(Fix::unsafe_edit(edit).isolate(isolation));
|
||||
|
|
|
@ -69,7 +69,7 @@ pub(crate) fn bad_dunder_method_name(checker: &Checker, method: &ast::StmtFuncti
|
|||
// If the name is explicitly allowed, skip it.
|
||||
if is_known_dunder_method(&method.name)
|
||||
|| checker
|
||||
.settings
|
||||
.settings()
|
||||
.pylint
|
||||
.allow_dunder_method_names
|
||||
.contains(method.name.as_str())
|
||||
|
|
|
@ -71,8 +71,8 @@ pub(crate) fn bad_staticmethod_argument(checker: &Checker, scope: &Scope) {
|
|||
decorator_list,
|
||||
parent,
|
||||
checker.semantic(),
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
);
|
||||
|
||||
match type_ {
|
||||
|
|
|
@ -91,7 +91,7 @@ fn is_banned_module_level_import(policy: &NameMatchPolicy, checker: &Checker) ->
|
|||
policy
|
||||
.find(
|
||||
checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_tidy_imports
|
||||
.banned_module_level_imports(),
|
||||
)
|
||||
|
|
|
@ -109,7 +109,7 @@ pub(crate) fn logging_call(checker: &Checker, call: &ast::ExprCall) {
|
|||
if !logging::is_logger_candidate(
|
||||
&call.func,
|
||||
checker.semantic(),
|
||||
&checker.settings.logger_objects,
|
||||
&checker.settings().logger_objects,
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ pub(crate) fn magic_value_comparison(checker: &Checker, left: &Expr, comparators
|
|||
|
||||
for comparison_expr in std::iter::once(left).chain(comparators) {
|
||||
if let Some(value) = as_literal(comparison_expr) {
|
||||
if is_magic_value(value, &checker.settings.pylint.allow_magic_value_types) {
|
||||
if is_magic_value(value, &checker.settings().pylint.allow_magic_value_types) {
|
||||
checker.report_diagnostic(
|
||||
MagicValueComparison {
|
||||
value: checker.locator().slice(comparison_expr).to_string(),
|
||||
|
|
|
@ -60,7 +60,7 @@ pub(crate) fn misplaced_bare_raise(checker: &Checker, raise: &ast::StmtRaise) {
|
|||
return;
|
||||
}
|
||||
|
||||
if in_dunder_method("__exit__", checker.semantic(), checker.settings) {
|
||||
if in_dunder_method("__exit__", checker.semantic(), checker.settings()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,15 +76,15 @@ pub(crate) fn no_self_use(checker: &Checker, scope_id: ScopeId, scope: &Scope) {
|
|||
decorator_list,
|
||||
parent,
|
||||
semantic,
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
),
|
||||
function_type::FunctionType::Method
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
let extra_property_decorators = checker.settings.pydocstyle.property_decorators();
|
||||
let extra_property_decorators = checker.settings().pydocstyle.property_decorators();
|
||||
|
||||
if function_type::is_stub(func, semantic)
|
||||
|| visibility::is_magic(name)
|
||||
|
|
|
@ -55,7 +55,7 @@ pub(crate) fn property_with_parameters(
|
|||
return;
|
||||
}
|
||||
let semantic = checker.semantic();
|
||||
let extra_property_decorators = checker.settings.pydocstyle.property_decorators();
|
||||
let extra_property_decorators = checker.settings().pydocstyle.property_decorators();
|
||||
if is_property(decorator_list, extra_property_decorators, semantic) {
|
||||
checker.report_diagnostic(PropertyWithParameters, stmt.identifier());
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ fn check_expr(checker: &Checker, expr: &Expr, names: &mut Vec<Name>) {
|
|||
check_expr(checker, &starred.value, names);
|
||||
}
|
||||
Expr::Name(ast::ExprName { id, .. }) => {
|
||||
if checker.settings.dummy_variable_rgx.is_match(id) {
|
||||
if checker.settings().dummy_variable_rgx.is_match(id) {
|
||||
// Ignore dummy variable assignments
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -346,7 +346,7 @@ pub(crate) fn redefined_loop_name(checker: &Checker, stmt: &Stmt) {
|
|||
let (outer_assignment_targets, inner_assignment_targets) = match stmt {
|
||||
Stmt::With(ast::StmtWith { items, body, .. }) => {
|
||||
let outer_assignment_targets: Vec<ExprWithOuterBindingKind> =
|
||||
assignment_targets_from_with_items(items, &checker.settings.dummy_variable_rgx)
|
||||
assignment_targets_from_with_items(items, &checker.settings().dummy_variable_rgx)
|
||||
.map(|expr| ExprWithOuterBindingKind {
|
||||
expr,
|
||||
binding_kind: OuterBindingKind::With,
|
||||
|
@ -354,7 +354,7 @@ pub(crate) fn redefined_loop_name(checker: &Checker, stmt: &Stmt) {
|
|||
.collect();
|
||||
let mut visitor = InnerForWithAssignTargetsVisitor {
|
||||
context: checker.semantic(),
|
||||
dummy_variable_rgx: &checker.settings.dummy_variable_rgx,
|
||||
dummy_variable_rgx: &checker.settings().dummy_variable_rgx,
|
||||
assignment_targets: vec![],
|
||||
};
|
||||
for stmt in body {
|
||||
|
@ -364,7 +364,7 @@ pub(crate) fn redefined_loop_name(checker: &Checker, stmt: &Stmt) {
|
|||
}
|
||||
Stmt::For(ast::StmtFor { target, body, .. }) => {
|
||||
let outer_assignment_targets: Vec<ExprWithOuterBindingKind> =
|
||||
assignment_targets_from_expr(target, &checker.settings.dummy_variable_rgx)
|
||||
assignment_targets_from_expr(target, &checker.settings().dummy_variable_rgx)
|
||||
.map(|expr| ExprWithOuterBindingKind {
|
||||
expr,
|
||||
binding_kind: OuterBindingKind::For,
|
||||
|
@ -372,7 +372,7 @@ pub(crate) fn redefined_loop_name(checker: &Checker, stmt: &Stmt) {
|
|||
.collect();
|
||||
let mut visitor = InnerForWithAssignTargetsVisitor {
|
||||
context: checker.semantic(),
|
||||
dummy_variable_rgx: &checker.settings.dummy_variable_rgx,
|
||||
dummy_variable_rgx: &checker.settings().dummy_variable_rgx,
|
||||
assignment_targets: vec![],
|
||||
};
|
||||
for stmt in body {
|
||||
|
|
|
@ -63,7 +63,7 @@ pub(crate) fn return_in_init(checker: &Checker, stmt: &Stmt) {
|
|||
}
|
||||
}
|
||||
|
||||
if in_dunder_method("__init__", checker.semantic(), checker.settings) {
|
||||
if in_dunder_method("__init__", checker.semantic(), checker.settings()) {
|
||||
checker.report_diagnostic(ReturnInInit, stmt.range());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ pub(crate) fn self_or_cls_assignment(checker: &Checker, target: &Expr) {
|
|||
decorator_list,
|
||||
parent,
|
||||
checker.semantic(),
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
);
|
||||
|
||||
let method_type = match (function_type, self_or_cls.name().as_str()) {
|
||||
|
|
|
@ -79,8 +79,8 @@ pub(crate) fn singledispatch_method(checker: &Checker, scope: &Scope) {
|
|||
decorator_list,
|
||||
parent,
|
||||
checker.semantic(),
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
);
|
||||
if !matches!(
|
||||
type_,
|
||||
|
|
|
@ -77,8 +77,8 @@ pub(crate) fn singledispatchmethod_function(checker: &Checker, scope: &Scope) {
|
|||
decorator_list,
|
||||
parent,
|
||||
checker.semantic(),
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
);
|
||||
if !matches!(type_, function_type::FunctionType::Function) {
|
||||
return;
|
||||
|
|
|
@ -96,8 +96,8 @@ pub(crate) fn super_without_brackets(checker: &Checker, func: &Expr) {
|
|||
&function_def.decorator_list,
|
||||
parent,
|
||||
checker.semantic(),
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
);
|
||||
if !matches!(
|
||||
classification,
|
||||
|
|
|
@ -68,10 +68,10 @@ pub(crate) fn too_many_arguments(checker: &Checker, function_def: &ast::StmtFunc
|
|||
let num_arguments = function_def
|
||||
.parameters
|
||||
.iter_non_variadic_params()
|
||||
.filter(|param| !checker.settings.dummy_variable_rgx.is_match(param.name()))
|
||||
.filter(|param| !checker.settings().dummy_variable_rgx.is_match(param.name()))
|
||||
.count();
|
||||
|
||||
if num_arguments <= checker.settings.pylint.max_args {
|
||||
if num_arguments <= checker.settings().pylint.max_args {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ pub(crate) fn too_many_arguments(checker: &Checker, function_def: &ast::StmtFunc
|
|||
&function_def.decorator_list,
|
||||
semantic.current_scope(),
|
||||
semantic,
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
),
|
||||
function_type::FunctionType::Method
|
||||
| function_type::FunctionType::ClassMethod
|
||||
|
@ -104,14 +104,14 @@ pub(crate) fn too_many_arguments(checker: &Checker, function_def: &ast::StmtFunc
|
|||
num_arguments
|
||||
};
|
||||
|
||||
if num_arguments <= checker.settings.pylint.max_args {
|
||||
if num_arguments <= checker.settings().pylint.max_args {
|
||||
return;
|
||||
}
|
||||
|
||||
checker.report_diagnostic(
|
||||
TooManyArguments {
|
||||
c_args: num_arguments,
|
||||
max_args: checker.settings.pylint.max_args,
|
||||
max_args: checker.settings().pylint.max_args,
|
||||
},
|
||||
function_def.identifier(),
|
||||
);
|
||||
|
|
|
@ -46,11 +46,11 @@ impl Violation for TooManyBooleanExpressions {
|
|||
pub(crate) fn too_many_boolean_expressions(checker: &Checker, stmt: &StmtIf) {
|
||||
if let Some(bool_op) = stmt.test.as_bool_op_expr() {
|
||||
let expressions = count_bools(bool_op);
|
||||
if expressions > checker.settings.pylint.max_bool_expr {
|
||||
if expressions > checker.settings().pylint.max_bool_expr {
|
||||
checker.report_diagnostic(
|
||||
TooManyBooleanExpressions {
|
||||
expressions,
|
||||
max_expressions: checker.settings.pylint.max_bool_expr,
|
||||
max_expressions: checker.settings().pylint.max_bool_expr,
|
||||
},
|
||||
bool_op.range(),
|
||||
);
|
||||
|
@ -60,11 +60,11 @@ pub(crate) fn too_many_boolean_expressions(checker: &Checker, stmt: &StmtIf) {
|
|||
for elif in &stmt.elif_else_clauses {
|
||||
if let Some(bool_op) = elif.test.as_ref().and_then(Expr::as_bool_op_expr) {
|
||||
let expressions = count_bools(bool_op);
|
||||
if expressions > checker.settings.pylint.max_bool_expr {
|
||||
if expressions > checker.settings().pylint.max_bool_expr {
|
||||
checker.report_diagnostic(
|
||||
TooManyBooleanExpressions {
|
||||
expressions,
|
||||
max_expressions: checker.settings.pylint.max_bool_expr,
|
||||
max_expressions: checker.settings().pylint.max_bool_expr,
|
||||
},
|
||||
bool_op.range(),
|
||||
);
|
||||
|
|
|
@ -45,12 +45,12 @@ pub(crate) fn too_many_locals(checker: &Checker, scope: &Scope) {
|
|||
binding.kind.is_assignment()
|
||||
})
|
||||
.count();
|
||||
if num_locals > checker.settings.pylint.max_locals {
|
||||
if num_locals > checker.settings().pylint.max_locals {
|
||||
if let ScopeKind::Function(func) = scope.kind {
|
||||
checker.report_diagnostic(
|
||||
TooManyLocals {
|
||||
current_amount: num_locals,
|
||||
max_amount: checker.settings.pylint.max_locals,
|
||||
max_amount: checker.settings().pylint.max_locals,
|
||||
},
|
||||
func.identifier(),
|
||||
);
|
||||
|
|
|
@ -48,7 +48,7 @@ pub(crate) fn too_many_nested_blocks(checker: &Checker, stmt: &Stmt) {
|
|||
return;
|
||||
}
|
||||
|
||||
let max_nested_blocks = checker.settings.pylint.max_nested_blocks;
|
||||
let max_nested_blocks = checker.settings().pylint.max_nested_blocks;
|
||||
|
||||
// Traverse up the hierarchy, identifying the root node and counting the number of nested
|
||||
// blocks between the root and this leaf.
|
||||
|
|
|
@ -72,10 +72,10 @@ pub(crate) fn too_many_positional_arguments(
|
|||
.posonlyargs
|
||||
.iter()
|
||||
.chain(&function_def.parameters.args)
|
||||
.filter(|param| !checker.settings.dummy_variable_rgx.is_match(param.name()))
|
||||
.filter(|param| !checker.settings().dummy_variable_rgx.is_match(param.name()))
|
||||
.count();
|
||||
|
||||
if num_positional_args <= checker.settings.pylint.max_positional_args {
|
||||
if num_positional_args <= checker.settings().pylint.max_positional_args {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,8 @@ pub(crate) fn too_many_positional_arguments(
|
|||
&function_def.decorator_list,
|
||||
semantic.current_scope(),
|
||||
semantic,
|
||||
&checker.settings.pep8_naming.classmethod_decorators,
|
||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||
&checker.settings().pep8_naming.classmethod_decorators,
|
||||
&checker.settings().pep8_naming.staticmethod_decorators,
|
||||
),
|
||||
function_type::FunctionType::Method
|
||||
| function_type::FunctionType::ClassMethod
|
||||
|
@ -108,14 +108,14 @@ pub(crate) fn too_many_positional_arguments(
|
|||
num_positional_args
|
||||
};
|
||||
|
||||
if num_positional_args <= checker.settings.pylint.max_positional_args {
|
||||
if num_positional_args <= checker.settings().pylint.max_positional_args {
|
||||
return;
|
||||
}
|
||||
|
||||
checker.report_diagnostic(
|
||||
TooManyPositionalArguments {
|
||||
c_pos: num_positional_args,
|
||||
max_pos: checker.settings.pylint.max_positional_args,
|
||||
max_pos: checker.settings().pylint.max_positional_args,
|
||||
},
|
||||
function_def.identifier(),
|
||||
);
|
||||
|
|
|
@ -75,7 +75,7 @@ pub(crate) fn useless_import_alias(checker: &Checker, alias: &Alias) {
|
|||
|
||||
// A re-export in __init__.py is probably intentional.
|
||||
if checker.path().ends_with("__init__.py")
|
||||
&& is_ignore_init_files_in_useless_alias_enabled(checker.settings)
|
||||
&& is_ignore_init_files_in_useless_alias_enabled(checker.settings())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ pub(crate) fn useless_import_alias(checker: &Checker, alias: &Alias) {
|
|||
// A required import with a useless alias causes an infinite loop.
|
||||
// See https://github.com/astral-sh/ruff/issues/14283
|
||||
let required_import_conflict = checker
|
||||
.settings
|
||||
.settings()
|
||||
.isort
|
||||
.requires_module_import(alias.name.to_string(), Some(asname.to_string()));
|
||||
let mut diagnostic = checker.report_diagnostic(
|
||||
|
@ -121,7 +121,7 @@ pub(crate) fn useless_import_from_alias(
|
|||
|
||||
// A required import with a useless alias causes an infinite loop.
|
||||
// See https://github.com/astral-sh/ruff/issues/14283
|
||||
let required_import_conflict = checker.settings.isort.requires_member_import(
|
||||
let required_import_conflict = checker.settings().isort.requires_member_import(
|
||||
module.map(str::to_string),
|
||||
alias.name.to_string(),
|
||||
Some(asname.to_string()),
|
||||
|
|
|
@ -40,7 +40,7 @@ impl Violation for YieldInInit {
|
|||
|
||||
/// PLE0100
|
||||
pub(crate) fn yield_in_init(checker: &Checker, expr: &Expr) {
|
||||
if in_dunder_method("__init__", checker.semantic(), checker.settings) {
|
||||
if in_dunder_method("__init__", checker.semantic(), checker.settings()) {
|
||||
checker.report_diagnostic(YieldInInit, expr.range());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ impl Violation for AccessAnnotationsFromClassDict {
|
|||
/// RUF063
|
||||
pub(crate) fn access_annotations_from_class_dict_with_get(checker: &Checker, call: &ExprCall) {
|
||||
let python_version = checker.target_version();
|
||||
let typing_extensions = checker.settings.typing_extensions;
|
||||
let typing_extensions = checker.settings().typing_extensions;
|
||||
|
||||
// Only apply this rule for Python 3.10 and newer unless `typing-extensions` is enabled.
|
||||
if python_version < PythonVersion::PY310 && !typing_extensions {
|
||||
|
@ -152,7 +152,7 @@ pub(crate) fn access_annotations_from_class_dict_by_key(
|
|||
subscript: &ExprSubscript,
|
||||
) {
|
||||
let python_version = checker.target_version();
|
||||
let typing_extensions = checker.settings.typing_extensions;
|
||||
let typing_extensions = checker.settings().typing_extensions;
|
||||
|
||||
// Only apply this rule for Python 3.10 and newer unless `typing-extensions` is enabled.
|
||||
if python_version < PythonVersion::PY310 && !typing_extensions {
|
||||
|
|
|
@ -205,7 +205,7 @@ pub(crate) fn ambiguous_unicode_character_string(checker: &Checker, string_like:
|
|||
ast::StringLikePart::String(string_literal) => {
|
||||
let text = checker.locator().slice(string_literal);
|
||||
for candidate in
|
||||
ambiguous_unicode_character(text, string_literal.range(), checker.settings)
|
||||
ambiguous_unicode_character(text, string_literal.range(), checker.settings())
|
||||
{
|
||||
candidate.report_diagnostic(checker, context);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ pub(crate) fn ambiguous_unicode_character_string(checker: &Checker, string_like:
|
|||
for literal in elements.literals() {
|
||||
let text = checker.locator().slice(literal);
|
||||
for candidate in
|
||||
ambiguous_unicode_character(text, literal.range(), checker.settings)
|
||||
ambiguous_unicode_character(text, literal.range(), checker.settings())
|
||||
{
|
||||
candidate.report_diagnostic(checker, context);
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ impl Candidate {
|
|||
|
||||
fn report_diagnostic(self, checker: &Checker, context: Context) {
|
||||
if !checker
|
||||
.settings
|
||||
.settings()
|
||||
.allowed_confusables
|
||||
.contains(&self.confusable)
|
||||
{
|
||||
|
|
|
@ -107,7 +107,7 @@ pub(crate) fn function_call_in_dataclass_default(checker: &Checker, class_def: &
|
|||
};
|
||||
|
||||
let extend_immutable_calls: Vec<QualifiedName> = checker
|
||||
.settings
|
||||
.settings()
|
||||
.flake8_bugbear
|
||||
.extend_immutable_calls
|
||||
.iter()
|
||||
|
|
|
@ -87,7 +87,7 @@ pub(crate) fn implicit_class_var_in_dataclass(checker: &mut Checker, class_def:
|
|||
continue;
|
||||
};
|
||||
|
||||
if checker.settings.dummy_variable_rgx.is_match(id.as_str()) {
|
||||
if checker.settings().dummy_variable_rgx.is_match(id.as_str()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ impl AlwaysFixableViolation for IncorrectlyParenthesizedTupleInSubscript {
|
|||
|
||||
/// RUF031
|
||||
pub(crate) fn subscript_with_parenthesized_tuple(checker: &Checker, subscript: &ExprSubscript) {
|
||||
let prefer_parentheses = checker.settings.ruff.parenthesize_tuple_in_subscript;
|
||||
let prefer_parentheses = checker.settings().ruff.parenthesize_tuple_in_subscript;
|
||||
|
||||
let Expr::Tuple(tuple_subscript) = &*subscript.slice else {
|
||||
return;
|
||||
|
|
|
@ -93,7 +93,7 @@ pub(crate) fn missing_fstring_syntax(checker: &Checker, literal: &ast::StringLit
|
|||
}
|
||||
}
|
||||
|
||||
let logger_objects = &checker.settings.logger_objects;
|
||||
let logger_objects = &checker.settings().logger_objects;
|
||||
let fastapi_seen = semantic.seen_module(Modules::FASTAPI);
|
||||
|
||||
// We also want to avoid:
|
||||
|
|
|
@ -69,7 +69,7 @@ fn remove_unused_variable(binding: &Binding, checker: &Checker) -> Option<Fix> {
|
|||
return None;
|
||||
}
|
||||
|
||||
if checker.settings.dummy_variable_rgx.is_match(&renamed) {
|
||||
if checker.settings().dummy_variable_rgx.is_match(&renamed) {
|
||||
let edit = Edit::range_replacement(renamed, binding.range());
|
||||
|
||||
return Some(Fix::unsafe_edit(edit).isolate(isolation));
|
||||
|
|
|
@ -157,7 +157,7 @@ pub(crate) fn used_dummy_variable(checker: &Checker, binding: &Binding, binding_
|
|||
{
|
||||
return;
|
||||
}
|
||||
if !checker.settings.dummy_variable_rgx.is_match(name) {
|
||||
if !checker.settings().dummy_variable_rgx.is_match(name) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ fn get_possible_new_name(
|
|||
};
|
||||
|
||||
// Check if the fix name is again dummy identifier
|
||||
if checker.settings.dummy_variable_rgx.is_match(&fix_name) {
|
||||
if checker.settings().dummy_variable_rgx.is_match(&fix_name) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ pub(crate) fn error_instead_of_exception(checker: &Checker, handlers: &[ExceptHa
|
|||
let ExceptHandler::ExceptHandler(ast::ExceptHandlerExceptHandler { body, .. }) = handler;
|
||||
let calls = {
|
||||
let mut visitor =
|
||||
LoggerCandidateVisitor::new(checker.semantic(), &checker.settings.logger_objects);
|
||||
LoggerCandidateVisitor::new(checker.semantic(), &checker.settings().logger_objects);
|
||||
visitor.visit_body(body);
|
||||
visitor.calls
|
||||
};
|
||||
|
|
|
@ -51,7 +51,7 @@ pub(crate) fn verbose_log_message(checker: &Checker, handlers: &[ExceptHandler])
|
|||
// Find all calls to `logging.exception`.
|
||||
let calls = {
|
||||
let mut visitor =
|
||||
LoggerCandidateVisitor::new(checker.semantic(), &checker.settings.logger_objects);
|
||||
LoggerCandidateVisitor::new(checker.semantic(), &checker.settings().logger_objects);
|
||||
visitor.visit_body(body);
|
||||
visitor.calls
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue