Git Product home page Git Product logo

fsort's Introduction

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:

pip install pre-commit

Then, add the following lines to your .pre-commit-config.yaml file:

- repos:
    - repo: https://github.com/unifyai/lint-hook
      rev: main
      hooks:
        - id: fsort

Usage

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:

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.

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.