Skip to content

Commit

Permalink
ruff: enable prefer f-string rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jelly committed Nov 3, 2023
1 parent d0614c5 commit 4a11883
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion devel/tests/test_devel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUp(self):
self.user.groups.add(Group.objects.get(name='Developers'))
self.user.save()
self.profile = UserProfile.objects.create(user=self.user,
public_email="{}@awesome.com".format(self.user.username))
public_email=f"{self.user.username}@awesome.com")
self.client.post('/login/', {
'username': self.user.username,
'password': password
Expand Down
8 changes: 4 additions & 4 deletions devel/tests/test_pgp_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
ID3 = 'B588C0234ECADD3F0BBBEEBA44F9F02E089294E7'

SIG_DATA = [
'pub:-:4096:1:{id1}:{created}:::-:::scESCA::::::23::0:'.format(id1=ID1, created=CREATED),
'fpr:::::::::{id2}:'.format(id2=ID2),
'uid:-::::{created}::{id3}::{user}::::::::::0:'.format(created=CREATED, id3=ID3, user=USER),
'sig:::1:{id1}:{created}::::{user}:13x::{id2}:::10:'.format(id1=ID1, created=CREATED, user=USER, id2=ID2)
f'pub:-:4096:1:{ID1}:{CREATED}:::-:::scESCA::::::23::0:',
f'fpr:::::::::{ID2}:',
f'uid:-::::{CREATED}::{ID3}::{USER}::::::::::0:',
f'sig:::1:{ID1}:{CREATED}::::{USER}:13x::{ID2}:::10:'
]


Expand Down
2 changes: 1 addition & 1 deletion devel/tests/test_reporead.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_read_packages(self):
if name != 'core.db' and 'desc' not in name]

packages = Package.objects.all()
import_packages = ["{}-{}-{}".format(pkg.pkgname, pkg.pkgver, pkg.pkgrel) for pkg in packages]
import_packages = [f"{pkg.pkgname}-{pkg.pkgver}-{pkg.pkgrel}" for pkg in packages]
self.assertCountEqual(files, import_packages)

def test_flagoutofdate(self):
Expand Down
2 changes: 1 addition & 1 deletion devel/tests/test_retire_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setUp(self):
last_name="User", email="[email protected]")

self.profile = UserProfile.objects.create(user=self.user,
public_email="{}@awesome.com".format(self.user.username))
public_email=f"{self.user.username}@awesome.com")
for name in ['Developers', 'Retired Developers']:
Group.objects.create(name=name)

Expand Down
2 changes: 1 addition & 1 deletion mirrors/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
SOURCE_IP = '127.0.0.1'
COUNTRY = 'DE'
PROTOCOL = 'https'
URL = '{}://{}'.format(PROTOCOL, HOSTNAME)
URL = f'{PROTOCOL}://{HOSTNAME}'


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion mirrors/tests/test_mirrorlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_mirrorlist(client, mirrorurl):

def test_mirrorlist_tier_last(client, mirrorurl):
last_tier = Mirror.TIER_CHOICES[-1][0]
response = client.get('/mirrorlist/tier/{}/'.format(last_tier + 1))
response = client.get(f'/mirrorlist/tier/{last_tier + 1}/')
assert response.status_code == 404


Expand Down
2 changes: 1 addition & 1 deletion mirrors/tests/test_mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ def test_details_downstream_json(db, client, downstream_mirror, mirrorprotocol):

def test_url_details(db, client, mirrorurl):
url = mirrorurl.mirror.get_absolute_url()
response = client.get(url + '{}/'.format(mirrorurl.id))
response = client.get(url + f'{mirrorurl.id}/')
assert response.status_code == 200
2 changes: 1 addition & 1 deletion mirrors/tests/test_mirrorurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_mirrorurl_overview(client, mirrorurl):


def test_mirrorurl_get_full_url(mirrorurl):
assert 'mirrors/{}'.format(mirrorurl.mirror.name) in mirrorurl.get_full_url()
assert f'mirrors/{mirrorurl.mirror.name}' in mirrorurl.get_full_url()


def test_mirror_url_clean(mirrorurl):
Expand Down
2 changes: 1 addition & 1 deletion mirrors/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_mirror_downstream(mirror):

def test_mirror_get_absolute_url(mirror):
absolute_url = mirror.get_absolute_url()
expected = '/mirrors/{}/'.format(mirror.name)
expected = f'/mirrors/{mirror.name}/'
assert absolute_url == expected


Expand Down
2 changes: 1 addition & 1 deletion news/tests/test_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_redirect_id(db, admin_client):
create(admin_client)
news = News.objects.first()

response = admin_client.get('/news/{}'.format(news.id), follow=True)
response = admin_client.get(f'/news/{news.id}', follow=True)
assert response.status_code == 200


Expand Down
2 changes: 1 addition & 1 deletion packages/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def test_feed(db, client):

def test_sitemap(db, client):
for sitemap in ['packages', 'package-groups', 'package-files', 'split-packages']:
response = client.get('/sitemap-{}.xml'.format(sitemap))
response = client.get(f'/sitemap-{sitemap}.xml')
assert response.status_code == 200


Expand Down
4 changes: 1 addition & 3 deletions packages/views/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,7 @@ def download(request, name, repo, arch, sig=False):
if pkg.arch.agnostic:
# grab the first non-any arch to fake the download path
arch = Arch.objects.exclude(agnostic=True)[0].name
url = '{host}{repo}/os/{arch}/{filename}'.format(host=url.url,
repo=pkg.repo.name.lower(),
arch=arch, filename=pkg.filename)
url = f'{url.url}{pkg.repo.name.lower()}/os/{arch}/{pkg.filename}'

if sig:
url = url + '.sig'
Expand Down
2 changes: 1 addition & 1 deletion public/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ def test_people(client, arches, repos, package, groups, staff_groups):
def test_sitemap(client, arches, repos, package, groups, staff_groups):
sitemaps = ['sitemap', 'sitemap-base']
for sitemap in sitemaps:
response = client.get('/{}.xml'.format(sitemap))
response = client.get(f'/{sitemap}.xml')
assert response.status_code == 200
4 changes: 2 additions & 2 deletions releng/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_absolute_url(release):
def test_iso_url(release):
url = release.iso_url()
ver = release.version
expected = 'iso/{}/archlinux-{}-x86_64.iso'.format(ver, ver)
expected = f'iso/{ver}/archlinux-{ver}-x86_64.iso'
assert url == expected


Expand All @@ -23,7 +23,7 @@ def test_info_html(release):


def test_dir_path(release):
dir_path = u'iso/{}/'.format(release.version)
dir_path = f'iso/{release.version}/'
assert dir_path == release.dir_path()


Expand Down
6 changes: 3 additions & 3 deletions releng/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ def test_netboot_config(db, client):


def test_release_torrent(client, release, torrent_data):
response = client.get('/releng/releases/{}/torrent/'.format(release.version))
response = client.get(f'/releng/releases/{release.version}/torrent/')
assert response.status_code == 404

release.torrent_data = torrent_data
release.save()
response = client.get('/releng/releases/{}/torrent/'.format(release.version))
response = client.get(f'/releng/releases/{release.version}/torrent/')
assert response.status_code == 200


def test_release_details(client, release):
response = client.get('/releng/releases/{}/'.format(release.version))
response = client.get(f'/releng/releases/{release.version}/')
assert response.status_code == 200
assert release.version in response.content.decode()
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ select = [
"PLE", # pylint errors
"T10", # flake8-debugger
"TCH", # flake8-type-checking
"UP032", # f-string
"W", # warnings (mostly whitespace)
]

Expand Down
2 changes: 1 addition & 1 deletion todolists/tests/test_templatetags_todolists.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

def test_details_link(todolistpackage):
link = todopkg_details_link(todolistpackage)
assert 'View package details for {}'.format(todolistpackage.pkg.pkgname) in link
assert f'View package details for {todolistpackage.pkg.pkgname}' in link
10 changes: 5 additions & 5 deletions todolists/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_flag_pkg(developer_client, arches, repos, package):
todolist = Todolist.objects.first()
package = todolist.packages().first()
assert package.status == TodolistPackage.INCOMPLETE
flag_url = '/todo/{}/flag/{}/'.format(todolist.slug, package.id)
flag_url = f'/todo/{todolist.slug}/flag/{package.id}/'

response = developer_client.get(flag_url)
assert response.status_code == 302
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_edit(developer_client, arches, repos, package):
todolist = Todolist.objects.first()
assert todolist.packages().count() == 1

response = developer_client.post('/todo/{}/edit/'.format(todolist.slug), {
response = developer_client.post(f'/todo/{todolist.slug}/edit/', {
'name': 'Foo rebuild',
'description': 'The Foo Rebuild, please read the instructions',
'raw': 'linux\nglibc',
Expand All @@ -86,12 +86,12 @@ def test_edit(developer_client, arches, repos, package):


def test_delete(developer_client, todolist):
response = developer_client.post('/todo/{}/delete'.format(todolist.slug))
response = developer_client.post(f'/todo/{todolist.slug}/delete')
assert response.status_code == 301


def test_json_endpoint(developer_client, todolist):
response = developer_client.post('/todo/{}/json'.format(todolist.slug))
response = developer_client.post(f'/todo/{todolist.slug}/json')
assert response.status_code == 200
data = response.json()
assert data['name'] == todolist.name
Expand All @@ -103,5 +103,5 @@ def test_add_view(developer_client):


def test_edit_view(developer_client, todolist):
response = developer_client.get('/todo/{}/edit/'.format(todolist.slug))
response = developer_client.get(f'/todo/{todolist.slug}/edit/')
assert response.status_code == 200
2 changes: 1 addition & 1 deletion visualize/tests/test_urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def test_urls(client, arches, repos, package):
for url in ['', 'by_repo/', 'by_arch/']:
response = client.get('/visualize/{}'.format(url))
response = client.get(f'/visualize/{url}')
assert response.status_code == 200

0 comments on commit 4a11883

Please sign in to comment.