Skip to main content

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 UV

Installation

Run the following command in the console:

uv add prune_norminette

Running the norminette

To run the package, simply enter in the console:

uv run prune_norminette

Display rules in the project

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

uv run norminette_display_rules

Norminette version

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

You can also pin the norminette to a specific version to avoid breaking changes, as the norminette is changing quickly.

Publish a new version

To publish a new version of the norminette, run ./publish.sh from the main branch. It will update pyproject.toml, create a git tab and push it to gitlab. This will trigger a CI/CD job to release the new version of the norminette on pypi.

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:

"""
    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.

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

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

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

Download

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 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.

Metadata

Release files for prune-norminette 2.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prune-norminette 2.0.7
File Size Uploaded
prune_norminette-2.0.7.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prune-norminette 2.0.7
File Interpreter ABI Platform
prune_norminette-2.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 68.2 kB

Release files / prune_norminette-2.0.7.tar.gz

Download URL prune_norminette-2.0.7.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9dd66ff9b6d16e2baac6e1bea195e4687056410c19a914e7fd126d53c078f4bb
BLAKE2b-256 checksum
How to use checksums
12c965fe08590c20e59622b68a27b50d35fb857db646d8d7ae6e6e10e5d301a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.9

Release files / prune_norminette-2.0.7-py3-none-any.whl

Download URL prune_norminette-2.0.7-py3-none-any.whl
Size 44.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fec46e85af4eb04e170cac981226a5337371b804e22d0b250768e6d05b1d2446
BLAKE2b-256 checksum
How to use checksums
d8d82e087654e9f990591152b1a207fad544d8c8eb182b8e9efea29a9b64fcb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

2.0.7 This release

2 release files

2.0.6

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page