Run Black over the whole codebase

This commit is contained in:
Danielle McLean 2023-08-10 16:52:37 +10:00
parent cd990e4e2f
commit 2e7d12b3e6
Signed by: 00dani
GPG key ID: 52C059C3B22A753E
109 changed files with 1539 additions and 1209 deletions

View file

@ -2,4 +2,4 @@ from django.apps import AppConfig
class LemonshortConfig(AppConfig):
name = 'lemonshort'
name = "lemonshort"

View file

@ -6,8 +6,9 @@ from string import ascii_lowercase, ascii_uppercase
chars = ascii_uppercase + ascii_lowercase
conv = BaseConverter(chars)
class AbcIdConverter:
regex = '[a-zA-Z]+'
regex = "[a-zA-Z]+"
def to_python(self, value: str) -> int:
return int(conv.decode(value))

View file

@ -11,7 +11,7 @@ def short_url(entity):
if not prefixes:
for k, m in settings.SHORTEN_MODELS.items():
prefixes[apps.get_model(m)] = k
base = '/'
if hasattr(settings, 'SHORT_BASE_URL'):
base = "/"
if hasattr(settings, "SHORT_BASE_URL"):
base = settings.SHORT_BASE_URL
return base + prefixes[type(entity)] + AbcIdConverter().to_url(entity.id)

View file

@ -3,14 +3,14 @@ from .. import convert
def test_to_python():
samples = {
'A': 0,
'B': 1,
'Y': 24,
'a': 26,
'b': 27,
'y': 50,
'BA': 52,
'BAB': 2705,
"A": 0,
"B": 1,
"Y": 24,
"a": 26,
"b": 27,
"y": 50,
"BA": 52,
"BAB": 2705,
}
converter = convert.AbcIdConverter()
for abc, id in samples.items():
@ -19,13 +19,13 @@ def test_to_python():
def test_id_to_abc():
samples = {
1: 'B',
24: 'Y',
26: 'a',
52: 'BA',
78: 'Ba',
104: 'CA',
130: 'Ca',
1: "B",
24: "Y",
26: "a",
52: "BA",
78: "Ba",
104: "CA",
130: "Ca",
}
converter = convert.AbcIdConverter()
for id, abc in samples.items():

View file

@ -4,10 +4,10 @@ from django.urls import path, register_converter
from .convert import AbcIdConverter
from .views import unshort
register_converter(AbcIdConverter, 'abc_id')
register_converter(AbcIdConverter, "abc_id")
app_name = 'lemonshort'
app_name = "lemonshort"
urlpatterns = tuple(
path('{0!s}<abc_id:tiny>'.format(k), unshort, name=m, kwargs={'model': m})
path("{0!s}<abc_id:tiny>".format(k), unshort, name=m, kwargs={"model": m})
for k, m in settings.SHORTEN_MODELS.items()
)