Metadata-Version: 2.1
Name: rubric
Version: 0.6.6
Summary: >> Linter Config Initialization for Python <<
Project-URL: Homepage, https://github.com/rednafi/rubric
Project-URL: Issue Tracker, https://github.com/pypa/rubric/issues
Author-email: rednafi <redowan.nafi@gmail.com>
License: MIT License
        
        Copyright (c) 2021 Redowan Delowar
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Requires-Dist: click
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: build; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: hatch; extra == 'dev'
Requires-Dist: isort; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pip-tools; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Requires-Dist: types-pkg-resources; extra == 'dev'
Requires-Dist: types-setuptools; extra == 'dev'
Description-Content-Type: text/markdown


<div align="center">

<h1>Rubric</h1>
<strong>>> <i>Linter Config Initializer for Python</i> <<</strong>

&nbsp;

</div>

![img](https://user-images.githubusercontent.com/30027932/122619075-6a87b700-d0b1-11eb-9d6b-355446910cc1.png)


## Preface

Rubric initializes the configuration files of a few Python linters and formatters. Also, it adds a README.md boilerplace and a simple Makefile with the commands to apply the tools. This helps you maintain an isomorphic workflow across multiple projects. It assumes that, in all of your Python projects, you'll use—

* [Black](https://github.com/psf/black) as the primary code formatter.
* [EditorConfig](https://editorconfig.org/) to enforce consistent coding styles for multiple developers.
* [Isort](https://github.com/PyCQA/isort) to sort the imports.
* [Flake8](https://github.com/PyCQA/flake8) to ensure style guide conformance.
* [Mypy](https://github.com/python/mypy) to check the type hints.
* [Pip-tools](https://github.com/jazzband/pip-tools) to manage the dependencies.
* [Pre-commit](https://pre-commit.com/) for managing and maintaining the pre-commit hooks.


Following is a list of config files that Rubric is going to add to your target directory:

```
root
├── .editorconfig           # Config file for Editorconfig
├── .flake8                 # Config file for .flake8
├── .gitignore              # Python specific .gitignore file
├── .pre-commit-config.yaml # Config to manage pre-commit hooks.
├── Makefile                # Makefile containing the commands to lint your code
├── pyproject.toml          # Toml file to with the configs for mypy, black & isort
├── README.md               # A readme boilerplate
├── requirements-dev.in     # File to specify the top level dev requirements
├── requirements-dev.txt    # File to specify the dev requirements
├── requirements.in         # File to specify the top level app requirements
└── requirements.txt        # File to specify the pinned app requirements
```

The files will contain minimal but sensible default configurations for the respective tools. You're free to change them as you like.

## Installation

* Rubric requires Python 3.8 and up.

* Make a virtual environment in your project's root directory.

* Activate the environment and run:

    ```
    pip install rubric
    ```

## Usage

* To inspect all the CLI options, run:

    ```
    rubric --help
    ```

    You should see the following output:

    ```
    $ rubric --help
                   >> Config Initializer for Python Projects <<

    Usage: rubric [OPTIONS]

    Options:
    -h, --help                      Display help message.
    -v, --version                   Display the version number.
    -s, --show                      Show the contents of the config files.
    -a, --append                    Append to existing config files.
    -o, --overwrite                 Overwrite existing config files.
    -c, --create                    Create the config files in the current
                                    directory.
    -f, --filename [.editorconfig|.flake8|.gitignore|.pre-commit-config.yaml|README.md|Makefile|pyproject.toml|requirements-dev.in|requirements-dev.txt|requirements.in|requirements.txt]
                                    Target file names.
    -d, --dirname PATH              Target directory name.
    -l, --list                      List the config files that are about to be
                                    generated.

    ```

* Display a list of config files that are going to be created:

    ```
    rubric --list
    ```

    ```
    Config files that are about to be generated:

    => .editorconfig
    => .flake8
    => .gitignore
    => .pre-commit-config.yaml
    => README.md
    => Makefile
    => pyproject.toml
    => requirements-dev.in
    => requirements-dev.txt
    => requirements.in
    => requirements.txt
    ```

* Take a peek into the content of any config file(s):
    ```
    rubric --show -f requirements.txt -f .flake8
    ```

    This will print:

    ```

    =============================== requirements.txt ===============================

    #
    # This file is autogenerated by pip-compile with python 3.10
    # To update, run:
    #
    #    pip-compile --output-file=requirements.txt requirements.in
    #

    =================================== .flake8 ===================================

    [flake8]
    extend-exclude =
        .git,
        __pycache__,
        docs/source/conf.py,
        old,
        build,
        dist,
        .venv,
        venv

    extend-ignore = E203, E266, E501, W605

    # Black's default line length.
    max-line-length = 88

    max-complexity = 18

    # Specify the list of error codes you wish Flake8 to report.
    select = B,C,E,F,W,T4,B9

    # Parallelism
    jobs = 4
    ```


* Initialize a project with the following command:

    ```
    rubric --create
    ```

    This will run the tool in a non-destructive way—that means it won't overwrite any of the configuration files that you might have in the directory.

* If you only want to create a selected list of config files, then run:

    ```
    rubric --create -f requirements.txt -f requirements-dev.txt
    ```

* If you want to overwrite any of the existing config files that you might have in the directory, then run:

    ```
    rubric --overwrite -f filename1 -f filename2
    ```

* If you want to append the configs to an existing file, then run:

    ```
    rubric --append -f filename1 -f filename2
    ```

* You can also point Rubric to a directory.

    ```
    rubric --create --directory "some/custom/directory"
    ```

* If you want to check and update the configs across multiple repositories in a single sweep, use the following command:

    ```
    s="dir1 dir2 dir3"; echo $s | xargs -n 1 -P $(echo $s | wc -w) rubric -c -d
    ```

    This command will spawn 3 processes to create the config files in `dir1`, `dir2`, and `dir3` in parallel.

* You can run the entire linter suite with this command:

    ```
    make lint
    ```

<div align="center">
<i> ✨ 🍰 ✨ </i>
</div>
