prune-norminette


Nameprune-norminette JSON
Version 2.0.2 PyPI version JSON
download
home_pageNone
SummaryA tool to ensure that code adheres to Prune's coding standards.
upload_time2025-09-04 09:16:57
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.12
licenseNone
keywords norminette django code-quality
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Prune's Norminette

## What is it for?

The norminette automatically checks the organization of files in a Django project as well as code rules.
This allows for the same code standard between projects and makes it easier to navigate.

## Prerequisites

-   To be installed on a Prune Django project that uses poetry or UV

## UV project

### Installation

Run the following command in the console:

```bash
uv add norminette_prune
```

### Running the norminette

To run the package, simply enter in the console:

```bash
norminette_prune
```

### Display rules in the project

To list all the rule checks in the project, run the following command:

```bash
norminette_display_rules
```

### Updating the norminette

Don't hesitate to regularly run `uv sync --upgrade`, as the norminette evolves with time and our practices!

## Poetry project

### Installation

Run the following command:

```bash
poetry add norminette_prune
```

### Running the norminette

```bash
poetry run norminette_prune
```

### Display rules in the project

To list all the rule checks in the project, run the following command:

```bash
poetry run norminette_display_rules
```

### Updating the norminette

Don't hesitate to regularly run `poetry update`, as the norminette evolves with time and our practices!

## For developers: add new rule

The rules are located in the `rules/` folder.

To add a new rule based on a function's docstring, follow this format:

```python
"""
    Id: 10
    Description: Describe what the rule checks.

    Tags:
        - Use relevant tags from the list below.

    Args:
        app (str): The name of the Django app to check.
        errors (list): A list to store error messages if the structure is incorrect.
"""
```

### Available Tags

The currently available tags are:

-   **web_files**: HTML, JS, and CSS files.
-   **python_files**: Python files with `.py` extension.
-   **architecture**: Checks folder and file placement consistency.
-   **format**: Directly modifies file formatting.
-   **files_content**: Inspects file contents.

### Integration Steps

-   Import the new function in `utils/run_checks.py`. (Remember to add errors in args)
-   Sync the new rules to update `README.md` and `README-FR.md`.

To sync rules after adding them to the project, run:

```bash
python -m norminette_prune.utils.rules.generate_readme
```

For adding a tag, add it to the `get_tags_descriptions()` function in `utils/rules/extract_rules.py` file.

## Project architecture at Prune

To access the documentation, please go to the link where you can find documentation in English and French.

[Documentation](https://gitlab.com/bastien_arnout/prune-doc.git)

If you want to download it directly, here is the link:

[Download](https://gitlab.com/bastien_arnout/prune-doc/-/archive/main/prune-doc-main.zip)

## Rules

| Id  | Name                                      | Description                                                                                                                                                           | Tags                           |
| :-: | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| 01  | check_view_function_naming                | Verify that the name of rendering functions for views ends with '\_view'.                                                                                             | python_files files_content     |
| 02  | check_pages_folder_structure              | Verify if `page.html` files are inside the `pages/` folder and ensure files in `pages/` are named `page` (except in `components`, `sections`, and `layouts` folders). | web_files architecture         |
| 03  | check_templates_static_structure          | Verify that the `static/` and `templates/` folders contain only one subfolder named after the app.                                                                    | architecture                   |
| 04  | remove_double_empty_lines                 | Remove double empty lines in HTML, JS, and CSS files.                                                                                                                 | format files_content web_files |
| 05  | normalize_django_tags_spacing             | Normalize spaces in Django tags (with exactly one space between the tag and its content).                                                                             | format web_files files_content |
| 06  | check_component_and_layout_file_placement | Verify that layout, component, and section files are correctly placed based on their `include` references.                                                            | web_files architecture         |
| 07  | check_svg_inclusion_paths                 | Ensure that SVG includes use absolute paths.                                                                                                                          | web_files files_content        |
| 08  | check_svg_files_location_and_extension    | Verify that SVG files are inside the `svg/` folder and use the `.html` extension.                                                                                     | web_files architecture         |
| 09  | check_uv_use                              | Verify if UV is used in the project by checking for 'uv.lock' in the current directory or subdirectories.                                                             | configuration                  |
| 10  | check_pyproject_configuration             | Verify if pyproject.toml exist and contain pydantic, ipython and whitenoise                                                                                           | configuration                  |
| 11  | check_for_envsettings_class_in_settings   | Verify if class EnvSettings exists in `settings.py`                                                                                                                   | configuration content_settings |
| 12  | check_environment_class_in_settings       | Verify if class Environment exists in `settings.py`                                                                                                                   | configuration content_settings |
| 13  | check_valid_whitenoise_and_static_paths   | Verify if WHITENOISE_ROOT and STATIC_ROOT have the correct paths.                                                                                                     | configuration content_settings |
| 14  | check_gitignore_content                   | Verify if ".env", ".venv", "**pycache**/", "node_modules/" and "static_root" are in `.gitignore` file                                                                 | configuration                  |
| 15  | check_core_model_usage                    | Checks if a model directly inherits from other than CoreModels.                                                                                                       | python_files files_content     |
| 17  | check_textchoices_in_enums                | Checks if TextChoices classes are defined in a file named 'enums.py'.                                                                                                 | python_files files_content     |
| 18  | check_missing_str_method                  | Checks if '**str**' method is present on `models.py`.                                                                                                                 | python_files files_content     |
| 19  | check_urls_name_parameter                 | Checks if all URL patterns in urls.py have a 'name' parameter.                                                                                                        | python_files files_content     |
| 20  | check_basemodel_in_payloads               | Checks if BaseModel (Pydantic) classes are defined in a file named 'payloads.py'.                                                                                     | python_files files_content     |

### Tags

-   **web_files** : HTML, JS, and CSS files.
-   **python_files** : Python files with `.py` extension.
-   **architecture** : Checks folder and file placement consistency.
-   **format** : Directly modifies file formatting.
-   **files_content** : Inspects file contents.
-   **configuration** : Verify project configuration.
-   **content_settings** : Verify settings.py configuration.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "prune-norminette",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.12",
    "maintainer_email": null,
    "keywords": "norminette, django, code-quality",
    "author": null,
    "author_email": "Arnout <bastien@prune.sh>",
    "download_url": "https://files.pythonhosted.org/packages/e1/1b/207dcf4cedefbd8c8c2daf46de10ef51b144294ce8464b0bdce1016f072c/prune_norminette-2.0.2.tar.gz",
    "platform": null,
    "description": "# Prune's Norminette\n\n## What is it for?\n\nThe norminette automatically checks the organization of files in a Django project as well as code rules.\nThis allows for the same code standard between projects and makes it easier to navigate.\n\n## Prerequisites\n\n-   To be installed on a Prune Django project that uses poetry or UV\n\n## UV project\n\n### Installation\n\nRun the following command in the console:\n\n```bash\nuv add norminette_prune\n```\n\n### Running the norminette\n\nTo run the package, simply enter in the console:\n\n```bash\nnorminette_prune\n```\n\n### Display rules in the project\n\nTo list all the rule checks in the project, run the following command:\n\n```bash\nnorminette_display_rules\n```\n\n### Updating the norminette\n\nDon't hesitate to regularly run `uv sync --upgrade`, as the norminette evolves with time and our practices!\n\n## Poetry project\n\n### Installation\n\nRun the following command:\n\n```bash\npoetry add norminette_prune\n```\n\n### Running the norminette\n\n```bash\npoetry run norminette_prune\n```\n\n### Display rules in the project\n\nTo list all the rule checks in the project, run the following command:\n\n```bash\npoetry run norminette_display_rules\n```\n\n### Updating the norminette\n\nDon't hesitate to regularly run `poetry update`, as the norminette evolves with time and our practices!\n\n## For developers: add new rule\n\nThe rules are located in the `rules/` folder.\n\nTo add a new rule based on a function's docstring, follow this format:\n\n```python\n\"\"\"\n    Id: 10\n    Description: Describe what the rule checks.\n\n    Tags:\n        - Use relevant tags from the list below.\n\n    Args:\n        app (str): The name of the Django app to check.\n        errors (list): A list to store error messages if the structure is incorrect.\n\"\"\"\n```\n\n### Available Tags\n\nThe currently available tags are:\n\n-   **web_files**: HTML, JS, and CSS files.\n-   **python_files**: Python files with `.py` extension.\n-   **architecture**: Checks folder and file placement consistency.\n-   **format**: Directly modifies file formatting.\n-   **files_content**: Inspects file contents.\n\n### Integration Steps\n\n-   Import the new function in `utils/run_checks.py`. (Remember to add errors in args)\n-   Sync the new rules to update `README.md` and `README-FR.md`.\n\nTo sync rules after adding them to the project, run:\n\n```bash\npython -m norminette_prune.utils.rules.generate_readme\n```\n\nFor adding a tag, add it to the `get_tags_descriptions()` function in `utils/rules/extract_rules.py` file.\n\n## Project architecture at Prune\n\nTo access the documentation, please go to the link where you can find documentation in English and French.\n\n[Documentation](https://gitlab.com/bastien_arnout/prune-doc.git)\n\nIf you want to download it directly, here is the link:\n\n[Download](https://gitlab.com/bastien_arnout/prune-doc/-/archive/main/prune-doc-main.zip)\n\n## Rules\n\n| Id  | Name                                      | Description                                                                                                                                                           | Tags                           |\n| :-: | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |\n| 01  | check_view_function_naming                | Verify that the name of rendering functions for views ends with '\\_view'.                                                                                             | python_files files_content     |\n| 02  | check_pages_folder_structure              | Verify if `page.html` files are inside the `pages/` folder and ensure files in `pages/` are named `page` (except in `components`, `sections`, and `layouts` folders). | web_files architecture         |\n| 03  | check_templates_static_structure          | Verify that the `static/` and `templates/` folders contain only one subfolder named after the app.                                                                    | architecture                   |\n| 04  | remove_double_empty_lines                 | Remove double empty lines in HTML, JS, and CSS files.                                                                                                                 | format files_content web_files |\n| 05  | normalize_django_tags_spacing             | Normalize spaces in Django tags (with exactly one space between the tag and its content).                                                                             | format web_files files_content |\n| 06  | check_component_and_layout_file_placement | Verify that layout, component, and section files are correctly placed based on their `include` references.                                                            | web_files architecture         |\n| 07  | check_svg_inclusion_paths                 | Ensure that SVG includes use absolute paths.                                                                                                                          | web_files files_content        |\n| 08  | check_svg_files_location_and_extension    | Verify that SVG files are inside the `svg/` folder and use the `.html` extension.                                                                                     | web_files architecture         |\n| 09  | check_uv_use                              | Verify if UV is used in the project by checking for 'uv.lock' in the current directory or subdirectories.                                                             | configuration                  |\n| 10  | check_pyproject_configuration             | Verify if pyproject.toml exist and contain pydantic, ipython and whitenoise                                                                                           | configuration                  |\n| 11  | check_for_envsettings_class_in_settings   | Verify if class EnvSettings exists in `settings.py`                                                                                                                   | configuration content_settings |\n| 12  | check_environment_class_in_settings       | Verify if class Environment exists in `settings.py`                                                                                                                   | configuration content_settings |\n| 13  | check_valid_whitenoise_and_static_paths   | Verify if WHITENOISE_ROOT and STATIC_ROOT have the correct paths.                                                                                                     | configuration content_settings |\n| 14  | check_gitignore_content                   | Verify if \".env\", \".venv\", \"**pycache**/\", \"node_modules/\" and \"static_root\" are in `.gitignore` file                                                                 | configuration                  |\n| 15  | check_core_model_usage                    | Checks if a model directly inherits from other than CoreModels.                                                                                                       | python_files files_content     |\n| 17  | check_textchoices_in_enums                | Checks if TextChoices classes are defined in a file named 'enums.py'.                                                                                                 | python_files files_content     |\n| 18  | check_missing_str_method                  | Checks if '**str**' method is present on `models.py`.                                                                                                                 | python_files files_content     |\n| 19  | check_urls_name_parameter                 | Checks if all URL patterns in urls.py have a 'name' parameter.                                                                                                        | python_files files_content     |\n| 20  | check_basemodel_in_payloads               | Checks if BaseModel (Pydantic) classes are defined in a file named 'payloads.py'.                                                                                     | python_files files_content     |\n\n### Tags\n\n-   **web_files** : HTML, JS, and CSS files.\n-   **python_files** : Python files with `.py` extension.\n-   **architecture** : Checks folder and file placement consistency.\n-   **format** : Directly modifies file formatting.\n-   **files_content** : Inspects file contents.\n-   **configuration** : Verify project configuration.\n-   **content_settings** : Verify settings.py configuration.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A tool to ensure that code adheres to Prune's coding standards.",
    "version": "2.0.2",
    "project_urls": {
        "Made_by": "https://prune.sh/"
    },
    "split_keywords": [
        "norminette",
        " django",
        " code-quality"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "35901ff5fa698ac9dc5393be58b97cc95a2e09053663a6210c61fd076379e93b",
                "md5": "c7cc2a590d522313c3a037dcaa99eb37",
                "sha256": "54cf79549ef959714b86143f2fbf4255b210b90834f6559f3e76cfd64216a818"
            },
            "downloads": -1,
            "filename": "prune_norminette-2.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c7cc2a590d522313c3a037dcaa99eb37",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 28256,
            "upload_time": "2025-09-04T09:16:56",
            "upload_time_iso_8601": "2025-09-04T09:16:56.821880Z",
            "url": "https://files.pythonhosted.org/packages/35/90/1ff5fa698ac9dc5393be58b97cc95a2e09053663a6210c61fd076379e93b/prune_norminette-2.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e11b207dcf4cedefbd8c8c2daf46de10ef51b144294ce8464b0bdce1016f072c",
                "md5": "fdb520dc293ad9c8788a65ea73be713f",
                "sha256": "9d9c7b6d4df4416b342804eb8b096400b8eca4d8512bba172d1c78642fb8638f"
            },
            "downloads": -1,
            "filename": "prune_norminette-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "fdb520dc293ad9c8788a65ea73be713f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 17697,
            "upload_time": "2025-09-04T09:16:57",
            "upload_time_iso_8601": "2025-09-04T09:16:57.686692Z",
            "url": "https://files.pythonhosted.org/packages/e1/1b/207dcf4cedefbd8c8c2daf46de10ef51b144294ce8464b0bdce1016f072c/prune_norminette-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-04 09:16:57",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "prune-norminette"
}
        
Elapsed time: 0.50300s