Skip to content

Commit 8708f7d

Browse files
authored
Fix pre commit + cleanup old compatibility code (#10)
Fix ruff settings
1 parent da859b3 commit 8708f7d

File tree

13 files changed

+126
-351
lines changed

13 files changed

+126
-351
lines changed

.github/workflows/lint.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: django-fsm linting
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v1
14+
- uses: actions/setup-python@v2
15+
with:
16+
python-version: '3.11'
17+
- uses: pre-commit/action@v3.0.0

.github/workflows/tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: django-fsm testing
22

33
on:
4-
- push
5-
- pull_request
4+
pull_request:
5+
push:
6+
branches: [main]
67

78
jobs:
89
build:

.pre-commit-config.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ repos:
1717
- id: end-of-file-fixer
1818
- id: trailing-whitespace
1919

20-
- repo: https://github.com/asottile/pyupgrade
21-
rev: v3.15.0
22-
hooks:
23-
- id: pyupgrade
24-
args:
25-
- "--py38-plus"
26-
2720
- repo: https://github.com/adamchainz/django-upgrade
2821
rev: 1.15.0
2922
hooks:
@@ -32,14 +25,14 @@ repos:
3225

3326

3427
- repo: https://github.com/python-poetry/poetry
35-
rev: 1.6.1
28+
rev: 1.6.0
3629
hooks:
3730
- id: poetry-check
38-
- id: poetry-lock
39-
- id: poetry-export
31+
# - id: poetry-lock
32+
# - id: poetry-export
4033

4134
- repo: https://github.com/astral-sh/ruff-pre-commit
42-
rev: v0.0.291
35+
rev: v0.1.3
4336
hooks:
4437
- id: ruff-format
4538
- id: ruff

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## django-fsm unreleased
44

5+
6+
- Remove South support...if exists
57
- Add support for django 5.0
68
- Remove support for django < 3.2
79
- Add support for python 3.12

CHANGELOG.rst

Lines changed: 0 additions & 161 deletions
This file was deleted.

django_fsm/__init__.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,13 @@
55
from functools import partialmethod, wraps
66

77
import django
8+
from django.apps import apps as django_apps
89
from django.db import models
910
from django.db.models import Field
1011
from django.db.models.query_utils import DeferredAttribute
1112
from django.db.models.signals import class_prepared
12-
from django_fsm.signals import pre_transition, post_transition
13-
14-
try:
15-
from django.apps import apps as django_apps
16-
17-
def get_model(app_label, model_name):
18-
app = django_apps.get_app_config(app_label)
19-
return app.get_model(model_name)
2013

21-
22-
except ImportError:
23-
from django.db.models.loading import get_model
14+
from django_fsm.signals import pre_transition, post_transition
2415

2516

2617
__all__ = [
@@ -38,16 +29,6 @@ def get_model(app_label, model_name):
3829
"RETURN_VALUE",
3930
]
4031

41-
# South support; see http://south.aeracode.org/docs/tutorial/part4.html#simple-inheritance
42-
try:
43-
from south.modelsinspector import add_introspection_rules
44-
except ImportError:
45-
pass
46-
else:
47-
add_introspection_rules([], [r"^django_fsm\.FSMField"])
48-
add_introspection_rules([], [r"^django_fsm\.FSMIntegerField"])
49-
add_introspection_rules([], [r"^django_fsm\.FSMKeyField"])
50-
5132

5233
class TransitionNotAllowed(Exception):
5334
"""Raised when a transition is not allowed"""
@@ -297,7 +278,8 @@ def set_proxy(self, instance, state):
297278
app_label = instance._meta.app_label
298279
model_name = state_proxy
299280

300-
model = get_model(app_label, model_name)
281+
model = django_apps.get_app_config(app_label).get_model(model_name)
282+
301283
if model is None:
302284
raise ValueError(f"No model found {state_proxy}")
303285

@@ -374,9 +356,7 @@ def contribute_to_class(self, cls, name, **kwargs):
374356
super().contribute_to_class(cls, name, **kwargs)
375357
setattr(cls, self.name, self.descriptor_class(self))
376358
setattr(cls, f"get_all_{self.name}_transitions", partialmethod(get_all_FIELD_transitions, field=self))
377-
setattr(
378-
cls, f"get_available_{self.name}_transitions", partialmethod(get_available_FIELD_transitions, field=self)
379-
)
359+
setattr(cls, f"get_available_{self.name}_transitions", partialmethod(get_available_FIELD_transitions, field=self))
380360
setattr(
381361
cls,
382362
f"get_available_user_{self.name}_transitions",

0 commit comments

Comments
 (0)