django-UrlConfChecks
a python package for type checking the urls and associated views
Installation
pip install django-urlconfchecks
Usage
Add this to your settings.py imports:
import django_urlconfchecks
Features
Using this package, URL pattern types will automatically be matched with associated views, and in case of mismatch, an error will be raised.
Example:
# urls.py
from django.urls import path
from . import views
urlpatterns = [
path('articles/<str:year>/', views.year_archive),
path('articles/<int:year>/<int:month>/', views.month_archive),
path('articles/<int:year>/<int:month>/<slug:slug>/', views.article_detail),
]
# views.py
def special_case(request):
pass
def year_archive(request, year: int):
pass
def month_archive(request, year: int, month: int):
pass
def article_detail(request, year: int, month: int, slug: str):
pass
output will be:
(urlchecker.E002) For parameter `year`, annotated type int does not match expected `str` from urlconf
- TODO
- Fine-grained methods for silencing checks.
- Should only warn for each unhandled Converter once
- Regex patterns perhaps? (only RoutePattern supported at the moment)
Credits
- Luke Plant for providing the idea and the initial code.
- This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.
Metadata
Release files for django-urlconfchecks 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-urlconfchecks-0.3.1.tar.gz | 19.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_urlconfchecks-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.7 kB
Release files / django-urlconfchecks-0.3.1.tar.gz
| Download URL | django-urlconfchecks-0.3.1.tar.gz |
|---|---|
| Size | 19.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59598386c2da43d7bb932b1df645dbe951bf50753502221bf89c28b110740ea2
|
|
BLAKE2b-256 checksum How to use checksums |
eb897f450569232f1d59251d81f29a3eb158dbc91e77a75b9644c2b7e39bd118
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Release files / django_urlconfchecks-0.3.1-py3-none-any.whl
| Download URL | django_urlconfchecks-0.3.1-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ed75aab4569263a35784ca8479d57fda263dcfdfe7531a3ebdef8e1f6f955cb
|
|
BLAKE2b-256 checksum How to use checksums |
b7b504471df03d239b5502f1ee7469bb27a69c10af6ea528b6fd31f806a0b2b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|