Sort methods, imports and classes in a python source file
Project description
Rearrange methods alphabetically in a Python source file. - Python3
sortorder
docstring
future imports
imports first on alphabet then on length (apo, alpha-pipe-organ)
from, modules on apo, imports on alpa
classes sorted on baseclassname then on classname alpha (internals of class unchanged)
methods sorted on methodname alpha
pep8
Can be combined with cp-pep8 for consistent readable code
sortpythonmethods -f myfile.py -w
python2 ~/cp.py -f myfile.py
example
Source file before sort
"""
Docstring is required
"""
import sys
import http
import email
import concurrent.futures
import os
class Zorro(object):
pass
class actie(object):
pass
def applemethod():
pass
def foobar():
pass
class Alpha1(object):
pass
def helloworld():
pass
class ZZ(object):
pass
class Alpha2(ZZ):
pass
Run command
sortpythonmethods -f myfile.py
Sorted source file
#!/usr/bin/env python3
# coding=utf-8
"""
Docstring is required
"""
import email
import http
import os
import sys
import concurrent.futures
class ZZ(object):
pass
class Alpha1(object):
pass
class Alpha2(ZZ):
pass
class Zorro(object):
pass
class actie(object):
pass
def applemethod():
pass
def foobar():
pass
def helloworld():
pass
completeness
baseclasses
globals
globalmethod calls
comments
todo
global pycharm directives
screenshot
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sortpythonmethods-15.tar.gz
(5.1 kB
view details)
File details
Details for the file sortpythonmethods-15.tar.gz
.
File metadata
- Download URL: sortpythonmethods-15.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df87330fd8942ba777240aeb2e1cccbd8360997b034b7183594320123c5c3a0f |
|
MD5 | f1cbf82816240d2ec95acc6f76b8d183 |
|
BLAKE2b-256 | e1c58dd28b3c457c1ae7fefd5f2dadee16552aa6241efb0e811e288b78223948 |