Skip to content

Commit

Permalink
Update Astral packages (ruff, uv, setup-uv GitHub action) (mozilla#3569)
Browse files Browse the repository at this point in the history
* Update Astral packages (ruff, uv, setup-uv GitHub action)
* Reformat files
  • Loading branch information
flodolo authored Feb 14, 2025
1 parent b0526d3 commit 5bf0f51
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ jobs:
with:
python-version: '3.11'
- name: Set up uv
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: |
**/requirements/*.txt
# Version should match the one used in docker/Dockerfile
version: "0.5.7"
version: "0.5.31"
- name: Install requirements
run: >
uv pip install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/py-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
with:
python-version: '3.11'
- name: Set up uv
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: |
**/requirements/*.txt
# Version should match the one used in docker/Dockerfile
version: "0.5.7"
version: "0.5.31"
- name: Install Dependencies
run: uv pip install -r requirements/lint.txt
env:
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN apt-get update \
&& apt-get autoremove -y

# Install uv (version should match the one used in Python GitHub workflows)
COPY --from=ghcr.io/astral-sh/uv:0.5.7 /uv /bin/uv
COPY --from=ghcr.io/astral-sh/uv:0.5.31 /uv /bin/uv

WORKDIR /app

Expand Down
8 changes: 4 additions & 4 deletions pontoon/base/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ def assert_attributes_equal(original, **expected_attrs):

for key, value in expected_attrs.items():
original_value = getattr(original, key)
assert (
original_value == value
), "Attribute `{key}` does not match: {original_value} != {value}".format(
key=key, original_value=original_value, value=value
assert original_value == value, (
"Attribute `{key}` does not match: {original_value} != {value}".format(
key=key, original_value=original_value, value=value
)
)


Expand Down
2 changes: 1 addition & 1 deletion pontoon/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def build_translation_memory_file(creation_date, locale_code, entries):
}
)

yield ("\n\t</body>" "\n</tmx>\n")
yield ("\n\t</body>\n</tmx>\n")


def get_m2m_changes(current_qs, new_qs):
Expand Down
20 changes: 10 additions & 10 deletions pontoon/contributors/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def get_contribution_graph_data(user, contribution_type=None):

return (
contributions_data,
f"{ intcomma(total) } contribution{ pluralize(total) } in the last year",
f"{intcomma(total)} contribution{pluralize(total)} in the last year",
)


Expand Down Expand Up @@ -381,11 +381,11 @@ def get_project_locale_contribution_counts(contributions_qs):
count = item["count"]

if item["action_type"] == "translation:created":
action = f"{ intcomma(count) } translation{ pluralize(count) }"
action = f"{intcomma(count)} translation{pluralize(count)}"
elif item["action_type"] == "translation:approved":
action = f"{ intcomma(count) } approved"
action = f"{intcomma(count)} approved"
elif item["action_type"] == "translation:rejected":
action = f"{ intcomma(count) } rejected"
action = f"{intcomma(count)} rejected"

if month not in counts:
counts[month] = {}
Expand Down Expand Up @@ -452,15 +452,15 @@ def get_contribution_timeline_data(
params_map = {
"user_translations": {
"author": user.email,
"time": f"{ start_ }-{ end_ }",
"time": f"{start_}-{end_}",
},
"user_reviews": {
"reviewer": user.email,
"review_time": f"{ start_ }-{ end_ }",
"review_time": f"{start_}-{end_}",
},
"peer_reviews": {
"author": user.email,
"review_time": f"{ start_ }-{ end_ }",
"review_time": f"{start_}-{end_}",
"exclude_self_reviewed": "",
},
}
Expand All @@ -476,11 +476,11 @@ def get_contribution_timeline_data(

# Generate title for the localizations belonging to the same contribution type
if contribution_type == "user_translations":
title = f"Submitted { intcomma(total_count) } translation{ pluralize(total_count) } in { intcomma(p_count) } project{ pluralize(p_count) }"
title = f"Submitted {intcomma(total_count)} translation{pluralize(total_count)} in {intcomma(p_count)} project{pluralize(p_count)}"
elif contribution_type == "user_reviews":
title = f"Reviewed { intcomma(total_count) } suggestion{ pluralize(total_count) } in { intcomma(p_count) } project{ pluralize(p_count) }"
title = f"Reviewed {intcomma(total_count)} suggestion{pluralize(total_count)} in {intcomma(p_count)} project{pluralize(p_count)}"
elif contribution_type == "peer_reviews":
title = f"Received review for { intcomma(total_count) } suggestion{ pluralize(total_count) } in { intcomma(p_count) } project{ pluralize(p_count) }"
title = f"Received review for {intcomma(total_count)} suggestion{pluralize(total_count)} in {intcomma(p_count)} project{pluralize(p_count)}"

# Generate localization URL and add it to the data dict
params = params_map[contribution_type]
Expand Down
2 changes: 1 addition & 1 deletion pontoon/machinery/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_view_caighdean_bad(client, entity_a):
assert response.status_code == 400
assert response.get("Content-Type") == "application/json"
assert json.loads(response.content)["message"] == (
"Bad Request: invalid literal for int() " "with base 10: 'DOESNOTEXIST'"
"Bad Request: invalid literal for int() with base 10: 'DOESNOTEXIST'"
)

maxid = Entity.objects.values_list("id", flat=True).order_by("-id").first()
Expand Down
26 changes: 13 additions & 13 deletions pontoon/messaging/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ def send_monthly_activity_summary():

recipient_count = len(users)

log.info(f"Monthly activity summary emails sent to { recipient_count } users.")
log.info(f"Monthly activity summary emails sent to {recipient_count} users.")


def send_notification_digest(frequency="Daily"):
"""
Sends notification email digests to users based on the specified frequency (Daily or Weekly).
"""
log.info(f"Start sending { frequency } notification email digests.")
log.info(f"Start sending {frequency} notification email digests.")

if frequency == "Daily":
start_time = timezone.now() - datetime.timedelta(days=1)
Expand Down Expand Up @@ -290,7 +290,7 @@ def send_notification_digest(frequency="Daily"):
if recipient.is_subscribed_to_notification(notification):
notifications_map[recipient].append(notification)

subject = f"{ frequency } notifications summary"
subject = f"{frequency} notifications summary"
template = get_template("messaging/emails/notification_digest.html")

# Process and send email for each user
Expand All @@ -314,7 +314,7 @@ def send_notification_digest(frequency="Daily"):

recipient_count = len(notifications_map.keys())

log.info(f"Notification email digests sent to { recipient_count } users.")
log.info(f"Notification email digests sent to {recipient_count} users.")


def send_onboarding_email_1(user):
Expand Down Expand Up @@ -348,7 +348,7 @@ def send_onboarding_email_1(user):
profile.onboarding_email_status = 1
profile.save(update_fields=["onboarding_email_status"])

log.info(f"1st onboarding email sent to { user.contact_email }.")
log.info(f"1st onboarding email sent to {user.contact_email}.")


def send_onboarding_emails_2(users):
Expand Down Expand Up @@ -384,7 +384,7 @@ def send_onboarding_emails_2(users):
pks = users.values_list("pk", flat=True)
UserProfile.objects.filter(user__in=pks).update(onboarding_email_status=2)

log.info(f"2nd onboarding emails sent to { len(users) } users.")
log.info(f"2nd onboarding emails sent to {len(users)} users.")


def send_onboarding_emails_3(users):
Expand Down Expand Up @@ -420,7 +420,7 @@ def send_onboarding_emails_3(users):
pks = users.values_list("pk", flat=True)
UserProfile.objects.filter(user__in=pks).update(onboarding_email_status=3)

log.info(f"3rd onboarding emails sent to { len(users) } users.")
log.info(f"3rd onboarding emails sent to {len(users)} users.")


def send_inactive_contributor_emails(users):
Expand Down Expand Up @@ -458,7 +458,7 @@ def send_inactive_contributor_emails(users):
now = timezone.now()
UserProfile.objects.filter(user__in=pks).update(last_inactive_reminder_sent=now)

log.info(f"Inactive contributor emails sent to { len(users) } users.")
log.info(f"Inactive contributor emails sent to {len(users)} users.")


def send_inactive_translator_emails(users, translator_map):
Expand All @@ -475,7 +475,7 @@ def send_inactive_translator_emails(users, translator_map):
try:
locale = list(translator_map[user.pk])[0]
except IndexError:
log.error(f"User { user } is not a translator of any locale.")
log.error(f"User {user} is not a translator of any locale.")
continue

content = jinja_env.from_string(email_content.body).render({"locale": locale})
Expand All @@ -501,7 +501,7 @@ def send_inactive_translator_emails(users, translator_map):
now = timezone.now()
UserProfile.objects.filter(user__in=pks).update(last_inactive_reminder_sent=now)

log.info(f"Inactive translator emails sent to { len(users) } users.")
log.info(f"Inactive translator emails sent to {len(users)} users.")


def send_inactive_manager_emails(users, manager_map):
Expand All @@ -518,7 +518,7 @@ def send_inactive_manager_emails(users, manager_map):
try:
locale = list(manager_map[user.pk])[0]
except IndexError:
log.error(f"User { user } is not a manager of any locale.")
log.error(f"User {user} is not a manager of any locale.")
continue

content = jinja_env.from_string(email_content.body).render({"locale": locale})
Expand All @@ -544,7 +544,7 @@ def send_inactive_manager_emails(users, manager_map):
now = timezone.now()
UserProfile.objects.filter(user__in=pks).update(last_inactive_reminder_sent=now)

log.info(f"Inactive manager emails sent to { len(users) } users.")
log.info(f"Inactive manager emails sent to {len(users)} users.")


def send_verification_email(user, link):
Expand Down Expand Up @@ -572,7 +572,7 @@ def send_verification_email(user, link):
msg.attach_alternative(body_html, "text/html")
msg.send()

log.info(f"Verification email sent to { user.contact_email }.")
log.info(f"Verification email sent to {user.contact_email}.")


@shared_task(bind=True)
Expand Down
2 changes: 1 addition & 1 deletion pontoon/sync/tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_translation_before_source():
tgt_root,
{
"de-Test": {
"a.ftl": ("a0 = New translation 0\n" "a1 = New translation 1\n"),
"a.ftl": ("a0 = New translation 0\na1 = New translation 1\n"),
"b.ftl": "b0 = Translation 0\n",
}
},
Expand Down
3 changes: 1 addition & 2 deletions pontoon/tour/migrations/0001_squashed_0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def create_tutorial_project(apps, schema_editor):
sync_disabled=True,
system_project=True,
info=(
"A tutorial project, used as a testing playground and for the "
"guided tour."
"A tutorial project, used as a testing playground and for the guided tour."
),
admin_notes=(
"Do not remove, this is required in code to show the guided tour."
Expand Down
2 changes: 1 addition & 1 deletion requirements/lint.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# The dependencies are sorted by alphabetical order.
# Dependencies that do not come from pypi (eg. eggs from github) are listed at the end of the list.
# -------------------------------------------------------------------------------------------------
ruff==0.8.2
ruff==0.9.6
38 changes: 19 additions & 19 deletions requirements/lint.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --generate-hashes --no-strip-extras requirements/lint.in -o requirements/lint.txt
ruff==0.8.2 \
--hash=sha256:1ca4e3a87496dc07d2427b7dd7ffa88a1e597c28dad65ae6433ecb9f2e4f022f \
--hash=sha256:2aae99ec70abf43372612a838d97bfe77d45146254568d94926e8ed5bbb409ea \
--hash=sha256:32096b41aaf7a5cc095fa45b4167b890e4c8d3fd217603f3634c92a541de7248 \
--hash=sha256:5fe716592ae8a376c2673fdfc1f5c0c193a6d0411f90a496863c99cd9e2ae25d \
--hash=sha256:60f578c11feb1d3d257b2fb043ddb47501ab4816e7e221fbb0077f0d5d4e7b6f \
--hash=sha256:705832cd7d85605cb7858d8a13d75993c8f3ef1397b0831289109e953d833d29 \
--hash=sha256:729850feed82ef2440aa27946ab39c18cb4a8889c1128a6d589ffa028ddcfc22 \
--hash=sha256:81c148825277e737493242b44c5388a300584d73d5774defa9245aaef55448b0 \
--hash=sha256:ac42caaa0411d6a7d9594363294416e0e48fc1279e1b0e948391695db2b3d5b1 \
--hash=sha256:b402ddee3d777683de60ff76da801fa7e5e8a71038f57ee53e903afbcefdaa58 \
--hash=sha256:b84f4f414dda8ac7f75075c1fa0b905ac0ff25361f42e6d5da681a465e0f78e5 \
--hash=sha256:c49ab4da37e7c457105aadfd2725e24305ff9bc908487a9bf8d548c6dad8bb3d \
--hash=sha256:cbd5cf9b0ae8f30eebc7b360171bd50f59ab29d39f06a670b3e4501a36ba5897 \
--hash=sha256:d261d7850c8367704874847d95febc698a950bf061c9475d4a8b7689adc4f7fa \
--hash=sha256:e769083da9439508833cfc7c23e351e1809e67f47c50248250ce1ac52c21fb93 \
--hash=sha256:ec016beb69ac16be416c435828be702ee694c0d722505f9c1f35e1b9c0cc1bf5 \
--hash=sha256:f05cdf8d050b30e2ba55c9b09330b51f9f97d36d4673213679b965d25a785f3c \
--hash=sha256:fb88e2a506b70cfbc2de6fae6681c4f944f7dd5f2fe87233a7233d888bad73e8
ruff==0.9.6 \
--hash=sha256:03482d5c09d90d4ee3f40d97578423698ad895c87314c4de39ed2af945633caa \
--hash=sha256:0e2bb706a2be7ddfea4a4af918562fdc1bcb16df255e5fa595bbd800ce322a5a \
--hash=sha256:194d8402bceef1b31164909540a597e0d913c0e4952015a5b40e28c146121b5d \
--hash=sha256:19f505b643228b417c1111a2a536424ddde0db4ef9023b9e04a46ed8a1cb4656 \
--hash=sha256:1de4367cca3dac99bcbd15c161404e849bb0bfd543664db39232648dc00112dc \
--hash=sha256:2f218f356dd2d995839f1941322ff021c72a492c470f0b26a34f844c29cdf5ba \
--hash=sha256:4a091729086dffa4bd070aa5dab7e39cc6b9d62eb2bef8f3d91172d30d599666 \
--hash=sha256:589d1d9f25b5754ff230dce914a174a7c951a85a4e9270613a2b74231fdac2f5 \
--hash=sha256:5dc1edd1775270e6aa2386119aea692039781429f0be1e0949ea5884e011aa8e \
--hash=sha256:5e2d9126161d0357e5c8f30b0bd6168d2c3872372f14481136d13de9937f79b6 \
--hash=sha256:68660eab1a8e65babb5229a1f97b46e3120923757a68b5413d8561f8a85d4897 \
--hash=sha256:81761592f72b620ec8fa1068a6fd00e98a5ebee342a3642efd84454f3031dca9 \
--hash=sha256:ac3ee4d7c2c92ddfdaedf0bf31b2b176fa7aa8950efc454628d477394d35638b \
--hash=sha256:b109c0ad2ececf42e75fa99dc4043ff72a357436bb171900714a9ea581ddef83 \
--hash=sha256:b908ff4df65dad7b251c9968a2e4560836d8f5487c2f0cc238321ed951ea0504 \
--hash=sha256:c4cae6c4cc7b9b4017c71114115db0445b00a16de3bcde0946273e8392856f08 \
--hash=sha256:d1bbc6808bf7b15796cef0815e1dfb796fbd383e7dbd4334709642649625e7c5 \
--hash=sha256:dc61dd5131742e21103fbbdcad683a8813be0e3c204472d520d9a5021ca8b217
# via -r requirements/lint.in

0 comments on commit 5bf0f51

Please sign in to comment.