Skip to content

Commit

Permalink
use black 24 (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek authored Mar 21, 2024
1 parent d280887 commit 92ca9b3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
9 changes: 5 additions & 4 deletions server/cp/commands/update_event_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class UpdateEventTypesCommand(superdesk.Command):

"""Update event_types in Vocabularies"""

"""
Expand Down Expand Up @@ -48,9 +47,11 @@ def run(self, filename: str):
"qcode": name,
"is_active": True,
"subject": self.get_subject(event),
"onclusive_ids": event["sourceMeta"][0]["key"]
if event.get("sourceMeta")
else None,
"onclusive_ids": (
event["sourceMeta"][0]["key"]
if event.get("sourceMeta")
else None
),
}
if type(event["name"]) is not str:
obj["translations"] = {
Expand Down
18 changes: 9 additions & 9 deletions server/cp/macros/usd_to_cad.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def repl(m, is_fr=False):
fixed = _format.format(converted).replace(".00", "")
# keep leeding whitespace so on client it won't
# replace $500 in C$500
diff[
m.group(0).rstrip()
] = "{whitespace} ({en_currency}{value}{mil}{fr_currency})".format(
whitespace=m.group(0).rstrip(),
en_currency="" if is_fr else "C$",
value=fixed if not is_fr else fixed.replace(",", " ").replace(".", ","),
mil=m.group("mil") or "",
fr_currency=" $ CAN" if is_fr else "",
).rstrip()
diff[m.group(0).rstrip()] = (
"{whitespace} ({en_currency}{value}{mil}{fr_currency})".format(
whitespace=m.group(0).rstrip(),
en_currency="" if is_fr else "C$",
value=fixed if not is_fr else fixed.replace(",", " ").replace(".", ","),
mil=m.group("mil") or "",
fr_currency=" $ CAN" if is_fr else "",
).rstrip()
)

re.sub(CURRENCY_REGEX, repl, text)
re.sub(CURRENCY_REGEX_FR, functools.partial(repl, is_fr=True), text)
Expand Down
6 changes: 3 additions & 3 deletions server/cp/output/formatter/newsmlg2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def _format_headline(self, article, content_meta):
try:
headline = article["extra"][cp.HEADLINE2]
SubElement(content_meta, "headline").text = headline
SubElement(
content_meta, "headline", attrib={"role": "short"}
).text = article.get("headline", "")
SubElement(content_meta, "headline", attrib={"role": "short"}).text = (
article.get("headline", "")
)
except KeyError:
super()._format_headline(article, content_meta)

Expand Down
6 changes: 3 additions & 3 deletions server/cp/planning_exports/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ def set_item_location(item, event):

item["address"] = {
"country": address["country"] if address.get("country") else None,
"locality": address["locality"]
if address.get("locality")
else None,
"locality": (
address["locality"] if address.get("locality") else None
),
"city": address["city"] if address.get("city") else "",
"state": address["state"] if address.get("state") else None,
"name": address.get("city") or address_item.get("name") or "",
Expand Down
2 changes: 1 addition & 1 deletion server/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mypy<=1.9.0
httmock==1.4.0
wooper==0.4.4
requests_mock
black~=23.0
black~=24.0

types-python-dateutil
types-pytz
Expand Down
6 changes: 3 additions & 3 deletions server/tests/output/publish_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def test_get_filename_non_jimi(self):
}
self.assertEqual("foo-bar.xml", CPPublishService.get_filename(queue_item))

queue_item[
"formatted_item"
] = "<?xml version='1.0' encoding='utf-8'?><test></test>"
queue_item["formatted_item"] = (
"<?xml version='1.0' encoding='utf-8'?><test></test>"
)
self.assertEqual("foo-bar.xml", CPPublishService.get_filename(queue_item))

queue_item[
Expand Down

0 comments on commit 92ca9b3

Please sign in to comment.