Giter Club home page Giter Club logo

asort's Introduction

asort's People

Contributors

cpendery avatar peterche1990 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

pombredanne

asort's Issues

asort improper transform

INDEX_TEMPLATE = """ loses the whitespace on the right side of the equal sign where it is the start of a multi line string

extra whitespace added after lines

On empty lines or lines that have multiline strings, extra whitespace is incorrectly added to the file. 1 space for newlines and many newline characters for the multiline strings; however, asort does not even report that the file has been changed. Occurring when using it as a pre-commit hook

Case-insensitive lexicographical sorting

Let's say I have the following __all__ already set:

$ cat ./__init__.py
from click import *
from cloup import *

__all__ = [
    "Argument",
    "argument",
    "BOOL",
    "Choice",
    "clear",
    "ClickException",
    "color_option",
    "ColorOption",
    ...
]

When running asort 0.1.3, I get the following results:

$ poetry run python -m pip install asort
Collecting asort
  Downloading asort-0.1.3-py3-none-any.whl (9.8 kB)
Installing collected packages: asort
Successfully installed asort-0.1.3

$ poetry run asort ./__init__.py

$ cat ./__init__.py
from click import *
from cloup import *

__all__ = [
    "Argument",
    "BOOL",
    "Choice",
    "ClickException",
    "ColorOption",
    "argument",
    "clear",
    "color_option",
    ...
]

You can see above how all title-cased and upper-cased strings bubble up at the top of the list. This is normal as it is the natural order of sorted strings in Python.

What I would like to have is a parameter or a configuration option so I can instead have the elements of the __all__ list sorted regardless of the case. I.e., in the case I presented here, I expect the __all__ to look like this:

__all__ = [
    "Argument",
    "argument",
    "BOOL",
    "Choice",
    "clear",
    "ClickException",
    "color_option",
    "ColorOption",
    ...
]

My main motivation to have this flavour of sorting is so I can visually inspect that for each of my main classe (like Argument), I have a corresponding decorator (the lower-cased argument) publicly available at the root of my library.

`asort` breaks docstring indention

Given the following minimal python code:

$ cat ./asort_indention.py
class Group:

    platform_ids: frozenset[str] = field(default_factory=frozenset)
    """Set of platform IDs that belong to this group.

    Used to test platform overlaps between groups.
    """

Passing that code above to asort is introducing bad docstring indention:

$ poetry run python -m pip install asort
Collecting asort
  Downloading asort-0.1.3-py3-none-any.whl (9.8 kB)
Installing collected packages: asort
Successfully installed asort-0.1.3

$ poetry run asort ./asort_indention.py

$ cat ./asort_indention.py
class Group:

    platform_ids: frozenset[str] = field(default_factory=frozenset)
"""Set of platform IDs that belong to this group.

    Used to test platform overlaps between groups.
    """

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.