a python package for type checking the urls and associated views.
Project description
django-UrlConfChecks
a python package for type checking the urls and associated views
- Documentation: https://AliSayyah.github.io/django-urlconfchecks
- GitHub: https://github.com/AliSayyah/django-urlconfchecks
- PyPI: https://pypi.org/project/django-urlconfchecks/
- Free software: GPL3
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.
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.3.0.tar.gz
(19.7 kB
view hashes)
Built Distribution
Close
Hashes for django-urlconfchecks-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11ad85810e880ad5b8bbe0b4fdd00b0308a0d9fe33e00f4d8f4328bca8792eb4 |
|
MD5 | 9cdf99e945a2fbf8d5478818b9ea8fce |
|
BLAKE2b-256 | d2a88df315ec69e696fc751c289dd39d6e550dddea4b69489cdfb7e8290e2157 |
Close
Hashes for django_urlconfchecks-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6883b097a478c33a5ef693ff81230f74c494f92ecf59184593c502eb7dfbd55 |
|
MD5 | d14e078a6864c8ca05d23897bef97caa |
|
BLAKE2b-256 | 71818d4c7686f8ab8ae67a051c20f6071a994633cab6f5c311f23d9ec70fc238 |