mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
Remove F401
fix for __init__
imports by default and allow opt-in to unsafe fix (#10365)
Re-implementation of https://github.com/astral-sh/ruff/pull/5845 but instead of deprecating the option I toggle the default. Now users can _opt-in_ via the setting which will give them an unsafe fix to remove the import. Otherwise, we raise violations but do not offer a fix. The setting is a bit of a misnomer in either case, maybe we'll want to remove it still someday. As discussed there, I think the safe fix should be to import it as an alias. I'm not sure. We need support for offering multiple fixes for ideal behavior though? I think we should remove the fix entirely and consider it separately. Closes https://github.com/astral-sh/ruff/issues/5697 Supersedes https://github.com/astral-sh/ruff/pull/5845 --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
c2e15f38ee
commit
7b3ee2daff
10 changed files with 81 additions and 25 deletions
|
@ -693,11 +693,14 @@ pub struct LintCommonOptions {
|
|||
/// imports will still be flagged, but with a dedicated message suggesting
|
||||
/// that the import is either added to the module's `__all__` symbol, or
|
||||
/// re-exported with a redundant alias (e.g., `import os as os`).
|
||||
///
|
||||
/// This option is enabled by default, but you can opt-in to removal of imports
|
||||
/// via an unsafe fix.
|
||||
#[option(
|
||||
default = "false",
|
||||
default = "true",
|
||||
value_type = "bool",
|
||||
example = r#"
|
||||
ignore-init-module-imports = true
|
||||
ignore-init-module-imports = false
|
||||
"#
|
||||
)]
|
||||
pub ignore_init_module_imports: Option<bool>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue