a python package for type checking the urls and associated views.
Project description
Django UrlConf Checks
a python package for type checking the urls and associated views
Installation
pip install django-urlconfchecks
Usage
Add django_urlconfchecks
to your INSTALLED_APPS
list in your settings.py
file.
INSTALLED_APPS = [
...
'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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-urlconfchecks-0.4.0.tar.gz
(20.4 kB
view hashes)
Built Distribution
Close
Hashes for django-urlconfchecks-0.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d6813493fe78a28bcab8babea70ac9d41789f11ae6201507887fb7f310ddd7d |
|
MD5 | e898fb0e7dc3224268dede0a89f8c519 |
|
BLAKE2b-256 | 85a84114939bd4de7522cde29f12fbc8cf2c8555ae6b668bb3d60d2b076ee304 |
Close
Hashes for django_urlconfchecks-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5820f6b85ae6957b9be423a5f0de064d4816b8cba353f3895c51d27d6b9697a0 |
|
MD5 | 037af5a73da95c0e72aafa19aff5a331 |
|
BLAKE2b-256 | 91895c984932472fd63f5ce984f05bd1cc3aa7ff252d9e8ba0736624b3d174b6 |