Sort the order of class functions and properties
Project description
seating
Sort the order of class functions, properties, and member variables.
Installation
Install with:
pip install seating
Sorting and Priority
- Class variables declared in class body outside of a function
- Dunder methods
- Functions decorated with
propertyor corresponding.setterand.deletermethods - Class functions
Each of these groups will be sorted alphabetically with respect to themselves.
The only exception is for dunder methods.
They will be sorted alphabetically except that __init__ will be first.
If you have class contents that are grouped a certain way and you want the groups individually sorted
so that the grouping is maintained, you can use # Seat to demarcate the groups.
i.e. if the source is:
class MyClass():
{arbitrary lines of code}
# Seat
{more arbitrary code}
# Seat
{yet more code}
then the three sets of code in brackets will be sorted independently from one another.
Usage
CLI
>seat -h
usage: seat [-h] [--start START] [--stop STOP] [-nb] [-o OUTPUT] [-d] file
positional arguments:
file The file to format.
options:
-h, --help show this help message and exit
--start START Optional line number to start formatting at.
--stop STOP Optional line number to stop formatting at.
-nb, --noblack Don't format file with Black after sorting.
-o OUTPUT, --output OUTPUT
Write changes to this file, otherwise changes are written back to the original file.
-d, --dump Dump ast tree to file instead of doing anything else. For debugging purposes.
Programmatically
from seating import seat
from pathier import Pathier
file = Pathier("somefile.py")
source = file.read_text()
source = seat(source)
file.write_text(source)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file seating-0.0.3.tar.gz.
File metadata
- Download URL: seating-0.0.3.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39898793f0da1a2025b8e81944b290306b469cc949764d3877be85cee251e120
|
|
| MD5 |
9868709f2a22b71bf08b3c65dd70b6d2
|
|
| BLAKE2b-256 |
6b78ce5a7ffecd4c4ac8f3190e1d9dfec30ff4d1c5128378286002e65e3df5c1
|
File details
Details for the file seating-0.0.3-py3-none-any.whl.
File metadata
- Download URL: seating-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c5162bed9692abd5180fd9a7ef5568664036b639f214ef8becaccfcf36fc0b7
|
|
| MD5 |
855fb676c699cfa6d6ec3c86ea326e49
|
|
| BLAKE2b-256 |
f1ed5aa595ae4210fbf9738e2ceac618d955aad99b369432ba46b03edb27c040
|