Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Add pre-commit hook for pyupgrade #410

Merged
merged 3 commits into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ repos:
language: system
types: [python]
require_serial: true
- id: pyupgrade
name: pyupgrade
description: Automatically upgrade syntax for newer versions.
entry: pyupgrade
language: system
types: [python]
args: [--py37-plus]
- id: reorder-python-imports
name: Reorder python imports
entry: reorder-python-imports
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def precommit(session: Session) -> None:
"pep8-naming",
"pre-commit",
"pre-commit-hooks",
"pyupgrade",
"reorder-python-imports",
)
session.run("pre-commit", *args)
Expand Down
77 changes: 46 additions & 31 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pre-commit-hooks = "^4.0.1"
typeguard = "^2.13.2"
sphinx-rtd-theme = "^1.0.0"
coverage = {version = "6.1.2", extras = ["toml"]}
pyupgrade = "^2.29.1"

[tool.coverage.paths]
source = ["src", "*/site-packages"]
Expand Down
4 changes: 2 additions & 2 deletions src/django_sorting_bootstrap/templatetags/sorting_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def result_headers(context, cl):
continue

# OK, it is sortable if we got this far
th_classes = ["sortable", "column-{}".format(field_name)]
th_classes = ["sortable", f"column-{field_name}"]
ascending = None
is_sorted = False
# Is it currently being sorted on?
Expand Down Expand Up @@ -173,7 +173,7 @@ def auto_sort(parser, token):
tag_name, queryset = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError(
"{} tag requires a single argument".format(token.contents.split()[0])
f"{token.contents.split()[0]} tag requires a single argument"
) from None
return SortedQuerysetNode(queryset)

Expand Down