Skip to content

aft_import: organize splits and mis-sorts groups; remove leaves the trailing comment behind #828

Open

Description

@null-axiom

AFT: 0.62.0, OpenCode 2.1.4, macOS.

aft_import grouping and comment handling:

  1. organize splits and mis-sorts groups (Python). Input:
    import sys
    import os
    import zeta.side  # noqa
    import abc
    from . import rel
    from collections import OrderedDict
    import json
    Result groups: os, sys → zeta.side → collections, abc, json. Stdlib is split around a third-party import, and the second stdlib group isn't sorted.
  2. organize leaves relative imports unsorted (TS). With import "./z-side"; import {z} from "./z"; // about y; import {y} from "./y"; import fs…; import "reflect-metadata"; import {x} from "./x"; import path…, ./x moves below the node imports after a blank line while ./z and ./y stay in original order.
  3. remove leaves the trailing comment behind. // about y / import { y } from "./y"; // trailing → after op: remove, module: ./y: // about y / // trailing (comment on its own line with a leading space). Expected the trailing comment (and arguably the leading one) to go with the import.

No imports were lost in any case; side-effect imports and comments between imports survived, and add merges into existing named imports correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions