Coder Social home page Coder Social logo

Comments (2)

amyreese avatar amyreese commented on May 5, 2024 2

µsort is intentionally using case-insensitive (specifically casefolded) sorting for both module names and imported names. We believe that is a usability benefit, as it means "frog", "Frog", and "FROG" will all sort next to each other, without a user needing to think about which implicit "section" of an import statement they will find an element in. We also do not intend to offer options to change this behavior, as that complicates the implementation and makes it harder to test and reason about safety of the resulting changes.

See the "comparison to isort" and "non-goals" sections of the user guide for further explanation: https://usort.readthedocs.io/en/stable/why.html

from usort.

thatch avatar thatch commented on May 5, 2024 1

Some additional context on how we got to this state:

  1. We want "import a" and "import B" to sort naturally. There are some real-world examples like "Queue" from py2, case-insensitive filesystems, and another one that we've seen internally that benefit from this.
  2. We want "from x import a" and "from x import B" to sort naturally. We can't tell easily whether "a" and "B" are modules or names within a module without introspecting the source. We don't want to require the source to be available, thus this needs to be chosen based only on the strings "a" and "B" (actually "x.a" and "x.B").
  3. We want to use the same rule for non-from imports.

The only choice that's straightforward to document and doesn't require the source is "all names are sorted case-insensitively." I wasn't a fan at first, but John convinced me this was much simpler to explain than something special-casey like "from imports are case-sensitive but everything else isn't."

from usort.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.