Skip to content

Commit d27ed8c

Browse files
authored
Merge pull request #169 from ticosax/pre-commit-django-upgrade
Add django-upgrade to our pre-commit checks
2 parents d29ed3f + 11715e2 commit d27ed8c

File tree

5 files changed

+12
-25
lines changed

5 files changed

+12
-25
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ repos:
2929
- "--line-length"
3030
- "119"
3131
exclude: ^django_fsm_log/migrations|^docs/
32+
- repo: https://github.com/adamchainz/django-upgrade
33+
rev: "1.13.0"
34+
hooks:
35+
- id: django-upgrade
36+
args: [--target-version, "3.2"]

django_fsm_log/backends.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,8 @@ def post_transition_callback(sender, instance, name, source, target, **kwargs):
8383

8484

8585
if settings.DJANGO_FSM_LOG_STORAGE_METHOD == "django_fsm_log.backends.CachedBackend":
86-
try:
87-
from django.core.cache import caches
88-
except ImportError:
89-
from django.core.cache import get_cache # Deprecated, removed in 1.9.
86+
from django.core.cache import caches
9087

91-
cache = get_cache(settings.DJANGO_FSM_LOG_CACHE_BACKEND)
92-
else:
93-
cache = caches[settings.DJANGO_FSM_LOG_CACHE_BACKEND]
88+
cache = caches[settings.DJANGO_FSM_LOG_CACHE_BACKEND]
9489
else:
9590
cache = None

tests/admin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from .models import Article
66

77

8+
@admin.register(Article)
89
class ArticleAdmin(admin.ModelAdmin):
910
inlines = [StateLogInline]
10-
11-
12-
admin.site.register(Article, ArticleAdmin)

tests/test_admin.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
try:
2-
from django.urls import reverse
3-
except ImportError:
4-
# django<=1.10
5-
from django.core.urlresolvers import reverse
1+
from django.urls import reverse
62

73

84
def test_state_log_inline_django2(article, admin_client, admin_user):

tests/urls.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
try:
2-
from django.contrib import admin
3-
from django.urls import path
1+
from django.contrib import admin
2+
from django.urls import path
43

5-
urlpatterns = [path("admin", admin.site.urls)]
6-
except ImportError:
7-
# django < 2.0
8-
from django.conf.urls import include, url
9-
from django.contrib import admin
10-
11-
urlpatterns = [url(r"^admin/", include(admin.site.urls))]
4+
urlpatterns = [path("admin", admin.site.urls)]

0 commit comments

Comments
 (0)