misc: update & run pre-commit for django-upgrade (#77825)

and update README
This commit is contained in:
Lauréline Guérin 2023-05-23 10:32:56 +02:00
parent 8e05d11780
commit b8e93014f5
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
4 changed files with 29 additions and 22 deletions

View File

@ -7,7 +7,7 @@ repos:
- id: pyupgrade
args: ['--keep-percent-format', '--py39-plus']
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.10.0
rev: 1.13.0
hooks:
- id: django-upgrade
args: ['--target-version', '3.2']

23
README
View File

@ -33,10 +33,27 @@ Code Style
black is used to format the code, using thoses parameters:
black --target-version py37 --skip-string-normalization --line-length 110
black --target-version py39 --skip-string-normalization --line-length 110
There is .pre-commit-config.yaml to use pre-commit to automatically run black
before commits. (execute `pre-commit install` to install the git hook.)
isort is used to format the imports, using those parameters:
isort --profile black --line-length 110
pyupgrade is used to automatically upgrade syntax, using those parameters:
pyupgrade --keep-percent-format --py39-plus
django-upgrade is used to automatically upgrade Django syntax, using those parameters:
django-upgrade --target-version 3.2
djhtml is used to automatically indent html files, using those parameters:
djhtml --tabwidth 2
There is .pre-commit-config.yaml to use pre-commit to automatically run black,
isort, pyupgrade, django-upgrade and djhtml before commits. (execute
`pre-commit install` to install the git hook.)
License

View File

@ -8,41 +8,31 @@ from django.views.decorators.cache import never_cache
from .models import InstalledService, Module, Platform, Project, Service
@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}
admin.site.register(Project, ProjectAdmin)
@admin.register(Platform)
class PlatformAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}
admin.site.register(Platform, PlatformAdmin)
@admin.register(Service)
class ServiceAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}
admin.site.register(Service, ServiceAdmin)
@admin.register(InstalledService)
class InstalledServiceAdmin(admin.ModelAdmin):
pass
admin.site.register(InstalledService, InstalledServiceAdmin)
@admin.register(Module)
class ModuleAdmin(admin.ModelAdmin):
pass
admin.site.register(Module, ModuleAdmin)
@never_cache
def login(request, *args, **kwargs):
try:

View File

@ -11,7 +11,7 @@ admin.autodiscover()
urlpatterns = [
path('', scrutiny.views.home, name='home'),
re_path(r'^projects/', include(projects_urls)),
path('projects/', include(projects_urls)),
re_path(r'^admin/', admin.site.urls),
path('logout/', scrutiny.views.logout, name='auth_logout'),
path('login/', scrutiny.views.login, name='auth_login'),
@ -21,11 +21,11 @@ urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if 'mellon' in settings.INSTALLED_APPS:
urlpatterns.append(re_path(r'^accounts/mellon/', include('mellon.urls')))
urlpatterns.append(path('accounts/mellon/', include('mellon.urls')))
if settings.DEBUG and 'debug_toolbar' in settings.INSTALLED_APPS:
import debug_toolbar # pylint: disable=import-error
urlpatterns = [
re_path(r'^__debug__/', include(debug_toolbar.urls)),
path('__debug__/', include(debug_toolbar.urls)),
] + urlpatterns