Skip to content

Commit

Permalink
chore: Use f-strings. Use %s when logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Dec 10, 2023
1 parent 084cf03 commit bd1f297
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions postcodes/management/commands/loadpostcodeconcordance.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def handle(self, *args, **options):
try:
(postcode, created) = Postcode.objects.get_or_create(code=code)
except ValidationError as e:
log.error("{}: {!r}".format(code, e))
log.error("%s: %s", code, repr(e))
continue

try:
Expand All @@ -70,12 +70,12 @@ def handle(self, *args, **options):
boundary = boundaries.get(**{options['search-field']: term})
boundaries_seen[term] = boundary
except Boundary.DoesNotExist:
log.error("No boundary {} matches {}".format(options['search-field'], term))
log.error("No boundary %s matches %s", options['search-field'], term)
continue

path = '{}/{}'.format(boundary_set.slug, boundary.slug)
path = f'{boundary_set.slug}/{boundary.slug}'
if PostcodeConcordance.objects.filter(code=postcode, boundary=path).exists():
log.warning("Concordance already exists between {} and {}".format(code, path))
log.warning("Concordance already exists between %s and %s", code, path)
continue

PostcodeConcordance.objects.create(
Expand Down
2 changes: 1 addition & 1 deletion postcodes/management/commands/loadpostcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def handle(self, *args, **options):
province=row['region'],
).save()
except ValidationError as e:
log.error("{}: {!r}".format(row['code'], e))
log.error("%s: %s", row['code'], repr(e))
2 changes: 1 addition & 1 deletion postcodes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ class Meta:
unique_together = (('code', 'boundary'))

def __str__(self):
return '{} -> {}'.format(self.code_id, self.boundary)
return f'{self.code_id} -> {self.boundary}'

0 comments on commit bd1f297

Please sign in to comment.