ruff
F401 - Recommend adding unused import bindings to `__all__`
#11314
Merged

Commits
  • Revert "patch to remove the unfinished dunder_all mutation"
    plredmond committed 1 year ago
  • charlie patch w/proto dunder_all finder
    plredmond committed 1 year ago
  • find_dunder_all_expr implemented
    plredmond committed 1 year ago
  • pass ExprList to fix_by_reexporting
    plredmond committed 1 year ago
  • slight cleanup of branch arms readability
    plredmond committed 1 year ago
  • rename F401_25__all fixture test to F401_25__all_nonempty
    plredmond committed 1 year ago
  • remove unnecessary pattern match
    plredmond committed 1 year ago
  • new field in ImportBinding which is the name of the binding
    plredmond committed 1 year ago
  • change fix_bind_reexporting call add_to_dunder_all with the list of binding names, /not import member_names/ to fix bug handling renamed imports; also to use a slice imput (per micha)
    plredmond committed 1 year ago
  • uncomment and review test cases for F401_25 fixture test
    plredmond committed 1 year ago
  • add edit to insert binding names into __all__
    plredmond committed 1 year ago
  • fixture tests to more thoroughly explore the cases of the "add to __all__" feature
    plredmond committed 1 year ago
  • cargo clippy edits -- map..or to map_or and single-pattern match to if..let
    plredmond committed 1 year ago
  • include the binding name in UnusedImport; when it is not the suffix of the qualified name, use the binding name in the fix title
    plredmond committed 1 year ago
  • accept fixture test changes that show the binding when it differs from the qualified name
    plredmond committed 1 year ago
  • accept stylist argument to place correct quotes around binders added to __all__; use "]".text_len() instead of specifying a TextSize manually
    plredmond committed 1 year ago
  • use Expr instead of ExprList to convey dunder_all value to the edit-producing function b/c we want to also support tuples
    plredmond committed 1 year ago
  • clippy again
    plredmond committed 1 year ago
  • change make_redundant_alias to take an iter of Cow to simplify caller
    plredmond committed 1 year ago
  • rewrite add_to_dunder_all and its tests
    plredmond committed 1 year ago
  • shakes fist at cloud and yells, "Clippy!!!"
    plredmond committed 1 year ago
  • change message for redundant-aliases
    plredmond committed 1 year ago
  • use binding method instead of accessing the field
    plredmond committed 1 year ago
  • use filter_map followed by last to obtain the first __all__ binding
    plredmond committed 1 year ago
  • update fixture test to reflect that we add to the first binding of __all__
    plredmond committed 1 year ago
  • fixture test to demonstrate how we treat __all__ followed by a conditional mutation
    plredmond committed 1 year ago
  • do not offer a fix to add to __all__ when there is more than one __all__; fall back to the redundant-alias recommending behavior
    plredmond committed 1 year ago
  • delete F401_29 fixture test
    plredmond committed 1 year ago
  • rename F401_30 fixture test to F401_29
    plredmond committed 1 year ago
  • add unused-import case to F401_29 fixture test
    plredmond committed 1 year ago
  • change `find_dunder_all_expr` to `find_dunder_all_exprs` and track the number of matches on UnusedImportContext::Init; update fix-title messaging and fix_by_reexporting to only fix when zero or one __all__ are present; update fixture tests
    plredmond committed 1 year ago
  • change find_dunder_all_exprs to return /all/ such exprs regardless of their types; the add_to_dunder_all fix-producing function will still only produce fixes for lists & tuples; update fixture test with non tuple/list __all__ to not recommend redundant alias
    plredmond committed 1 year ago
  • change fix-title for redundant alias case to format itself and return early
    plredmond committed 1 year ago
  • use if-let instead of match with empty branch per alex
    plredmond committed 1 year ago
  • Update crates/ruff_linter/src/fix/edits.rs
    plredmond committed 1 year ago
  • wording improvement per alex
    plredmond committed 1 year ago
  • replace into::Into with Cow::from to make conversion explicit
    plredmond committed 1 year ago
  • improve the wording of "add unused import to __all__" message per alex
    plredmond committed 1 year ago
  • reformat a function -- noop w.r.t. the tests
    plredmond committed 1 year ago
  • remove a now unnecessary branch, which also makes the overall PR diff smaller
    plredmond committed 1 year ago
  • call .end() directly instead of going through .range or .range(); remove unnecessary import paths
    plredmond committed 1 year ago
  • readd erroneously removed newlines to fixture snaps
    plredmond committed 1 year ago
  • ruff format the fixture __init__.py files
    plredmond committed 1 year ago
  • cargo insta review -- accept whitespace changes (see `git diff -w`)
    plredmond committed 1 year ago
  • clippy fix -- replace closure with static reference to method
    plredmond committed 1 year ago
  • collect only 2 `__all__` definitions and then stop pulling the iterator
    plredmond committed 1 year ago
  • Revert "collect only 2 `__all__` definitions and then stop pulling the iterator"
    plredmond committed 1 year ago
  • remove the qualified-name field from UnusedImport in favor of the binding-name field (named as .name); update fixture test results
    plredmond committed 1 year ago
  • Revert "remove the qualified-name field from UnusedImport in favor of the binding-name field (named as .name); update fixture test results"
    plredmond committed 1 year ago
Loading