Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nripeshn/fsort
https://github.com/nripeshn/fsort
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nripeshn/fsort
- Owner: NripeshN
- License: apache-2.0
- Created: 2024-01-05T20:31:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-05T21:37:00.000Z (about 1 year ago)
- Last Synced: 2024-01-05T22:27:33.956Z (about 1 year ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=======================================
Function Sorting Hook for Python Code
=======================================Introduction
============
This project introduces a pre-commit hook named `fsort`, which is designed to
rearrange Python functions and classes in a logical order. It ensures that your
Python code is structured in a way that enhances readability and maintainability.The `fsort` hook uses advanced techniques, including dependency graphs, to
analyze the relationships between different parts of the code. It then rearranges
the elements, such as imports, class definitions, function definitions, and
assignments, based on these relationships.Installation
============
To use `fsort`, you need to have `pre-commit` installed in your Python environment.
If you don't have `pre-commit` installed, you can install it using pip:.. code-block:: bash
pip install pre-commit
Then, add the following lines to your `.pre-commit-config.yaml` file:
.. code:: yaml
- repos:
- repo: https://github.com/unifyai/lint-hook
rev: main
hooks:
- id: fsortUsage
=====
Once you have added `fsort` to your pre-commit configuration, it will automatically
run whenever you commit your changes. `fsort` will analyze your Python files and
rearrange the functions and classes as per the logical ordering defined in its
algorithm.To manually run `fsort` on all files in the repository, you can use:
.. code-block:: bash
pre-commit run fsort --all-files
Contributing
============
Contributions to `fsort` are welcome! If you have suggestions for improvements or
want to contribute code, please feel free to open an issue or a pull request on our
GitHub repository.