mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-16 20:00:23 +00:00
Add pyupgrade to pre-commit configurations
This commit is contained in:
parent
8723a0e34e
commit
0b5475e3d5
4 changed files with 11 additions and 5 deletions
|
|
@ -12,3 +12,9 @@ repos:
|
|||
- id: flake8
|
||||
args: ['--ignore=E402,E501,E731,W503']
|
||||
files: ^(model_utils|tests)/
|
||||
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.37.3
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py37-plus]
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class InheritanceQuerySetMixin:
|
|||
"""
|
||||
if not issubclass(model, self.model):
|
||||
raise ValueError(
|
||||
"{!r} is not a subclass of {!r}".format(model, self.model))
|
||||
f"{model!r} is not a subclass of {self.model!r}")
|
||||
|
||||
ancestry = []
|
||||
# should be a OneToOneField or None
|
||||
|
|
@ -308,7 +308,7 @@ class JoinQueryset(models.QuerySet):
|
|||
|
||||
# Put additional quotes around string.
|
||||
params = [
|
||||
'\'{}\''.format(p)
|
||||
f'\'{p}\''
|
||||
if isinstance(p, str) else p
|
||||
for p in params
|
||||
]
|
||||
|
|
@ -338,7 +338,7 @@ class JoinQueryset(models.QuerySet):
|
|||
if getattr(fk, 'related_model', None) == self.model
|
||||
]
|
||||
fk = fk[0] if fk else None
|
||||
model_set = '{}_set'.format(self.model.__name__.lower())
|
||||
model_set = f'{self.model.__name__.lower()}_set'
|
||||
key = fk or getattr(qs.model, model_set, None)
|
||||
|
||||
if not key:
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -8,7 +8,7 @@ def long_desc(root_path):
|
|||
for filename in FILES:
|
||||
filepath = os.path.realpath(os.path.join(root_path, filename))
|
||||
if os.path.isfile(filepath):
|
||||
with open(filepath, mode='r') as f:
|
||||
with open(filepath) as f:
|
||||
yield f.read()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from tests.models import BoxJoinModel, JoinItemForeignKey
|
|||
class JoinManagerTest(TestCase):
|
||||
def setUp(self):
|
||||
for i in range(20):
|
||||
BoxJoinModel.objects.create(name='name_{i}'.format(i=i))
|
||||
BoxJoinModel.objects.create(name=f'name_{i}')
|
||||
|
||||
JoinItemForeignKey.objects.create(
|
||||
weight=10, belonging=BoxJoinModel.objects.get(name='name_1')
|
||||
|
|
|
|||
Loading…
Reference in a new issue