Skip to content

Commit

Permalink
Merge pull request #3672 from freelawproject/black-changes
Browse files Browse the repository at this point in the history
Update Black to match release
  • Loading branch information
mlissner authored Jan 26, 2024
2 parents 998b207 + dbfb295 commit c8b0257
Show file tree
Hide file tree
Showing 35 changed files with 119 additions and 98 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
7ccaf6cc24f3f3a6ec0b5e32f26b9314dad80d79
ff2bcc3ea7dd467e2b9fc276a086f7953958511b
ee43b40ac13e0db8275018cb43380aeb24751795
30099991642874440a818585a44193d75db27309
d37a81620f9ed2eaa542dff8389806f2df6aa0ac

# Eslint
e0d8f6cbca7455e63c9b0234f22d30d5abf56b94
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
args: [--line-length=79, --transform-concats]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.0
hooks:
- id: black

Expand Down
1 change: 1 addition & 0 deletions cl/api/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
replication lag, and we can just apply this with the `using` argument wherever
we want. Much simpler, though perhaps less elegant.
"""

import itertools
import random

Expand Down
12 changes: 6 additions & 6 deletions cl/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,13 +835,13 @@ async def test_docket_filters(self) -> None:
self.q["clusters__panel__name_first__istartswith"] = "jud"
await self.assertCountInResults(1)

self.q[
"audio_files__sha1"
] = "de8cff186eb263dc06bdc5340860eb6809f898d3-nope"
self.q["audio_files__sha1"] = (
"de8cff186eb263dc06bdc5340860eb6809f898d3-nope"
)
await self.assertCountInResults(0)
self.q[
"audio_files__sha1"
] = "de8cff186eb263dc06bdc5340860eb6809f898d3"
self.q["audio_files__sha1"] = (
"de8cff186eb263dc06bdc5340860eb6809f898d3"
)
await self.assertCountInResults(1)

async def test_audio_filters(self) -> None:
Expand Down
6 changes: 3 additions & 3 deletions cl/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ def determine_metadata(self, request, view):
model_name = (
filter_type.filterset.Meta.model._meta.verbose_name_plural.title()
)
attrs[
"lookup_types"
] = f"See available filters for '{model_name}'"
attrs["lookup_types"] = (
f"See available filters for '{model_name}'"
)
else:
attrs["lookup_types"] = ["exact"]

Expand Down
6 changes: 3 additions & 3 deletions cl/audio/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def feed_extra_kwargs(self, obj):
else:
# Not a jurisdiction API -- A search API.
path = static("png/producer-2000x2000.png")
extra_args[
"iTunes_image_url"
] = f"https://storage.courtlistener.com{path}"
extra_args["iTunes_image_url"] = (
f"https://storage.courtlistener.com{path}"
)

return extra_args

Expand Down
8 changes: 3 additions & 5 deletions cl/corpus_importer/import_columbia/columbia_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,9 @@ def find_dates_in_xml(soup: BeautifulSoup) -> dict:
)
parsed_dates = parse_dates(found_dates)
current_year = date.today().year
date_filed = (
date_argued
) = (
date_reargued
) = date_reargument_denied = date_cert_granted = date_cert_denied = None
date_filed = date_argued = date_reargued = date_reargument_denied = (
date_cert_granted
) = date_cert_denied = None
unknown_date = None

for date_cluster in parsed_dates:
Expand Down
8 changes: 5 additions & 3 deletions cl/corpus_importer/import_columbia/html_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,11 @@ def get_text(file_path):
raw_info.setdefault("opinions", []).append(
{
"type": opinion_type,
"byline": current_byline["name"]
if current_byline["type"] == opinion_type
else None,
"byline": (
current_byline["name"]
if current_byline["type"] == opinion_type
else None
),
"opinion": get_xml_string(child),
}
)
Expand Down
8 changes: 5 additions & 3 deletions cl/corpus_importer/import_columbia/parse_opinions.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,11 @@ def get_text(file_path):
raw_info.setdefault("opinions", []).append(
{
"type": opinion_type,
"byline": current_byline["name"]
if current_byline["type"] == opinion_type
else None,
"byline": (
current_byline["name"]
if current_byline["type"] == opinion_type
else None
),
"opinion": get_xml_string(child),
}
)
Expand Down
8 changes: 3 additions & 5 deletions cl/corpus_importer/import_columbia/populate_opinions.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ def make_and_save(
min_date: if not none, will skip cases after min_date
"""
date_filed = (
date_argued
) = (
date_reargued
) = date_reargument_denied = date_cert_granted = date_cert_denied = None
date_filed = date_argued = date_reargued = date_reargument_denied = (
date_cert_granted
) = date_cert_denied = None
unknown_date = None
for date_cluster in item["dates"]:
for date_info in date_cluster:
Expand Down
15 changes: 9 additions & 6 deletions cl/corpus_importer/management/commands/columbia_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""

import os.path
import re
from difflib import SequenceMatcher
Expand Down Expand Up @@ -254,9 +255,11 @@ def map_and_merge_opinions(
per_curiam=op["per_curiam"],
cluster_id=cluster_id,
type=opinion_type,
author_str=titlecase(find_just_name(author.strip(":")))
if author
else "",
author_str=(
titlecase(find_just_name(author.strip(":")))
if author
else ""
),
)

logger.info(f"Opinion created for cluster: {cluster_id}")
Expand Down Expand Up @@ -450,9 +453,9 @@ def process_cluster(
"file": filepath,
"attorneys": attorneys,
"citations": fetch_simple_tags(soup, "citation"),
"docket_number": clean_docket_number(docket_number)
if docket_number
else None,
"docket_number": (
clean_docket_number(docket_number) if docket_number else None
),
"panel": extract_judge_last_name(panel_tags),
"posture": posture,
"case_name": format_case_name(reporter_captions),
Expand Down
10 changes: 5 additions & 5 deletions cl/corpus_importer/management/commands/harvard_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,11 @@ def map_and_merge_opinions(
xml_harvard=str(op),
cluster_id=cluster.id,
type=opinion_type,
author_str=titlecase(
find_just_name(author.text.strip(":"))
)
if author
else "",
author_str=(
titlecase(find_just_name(author.text.strip(":")))
if author
else ""
),
)
else:
raise OpinionTypeException(
Expand Down
6 changes: 3 additions & 3 deletions cl/corpus_importer/management/commands/troller_bk.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ async def merge_rss_data(
dockets_to_create: list[Docket] = []
unique_dockets: dict[str, Any] = {}
des_to_add_existing_docket: list[tuple[int, dict[str, Any]]] = []
des_to_add_no_existing_docket: DefaultDict[
str, list[dict[str, Any]]
] = defaultdict(list)
des_to_add_no_existing_docket: DefaultDict[str, list[dict[str, Any]]] = (
defaultdict(list)
)
for docket in feed_data:
skip_or_break = await check_for_early_termination(court_id, docket)
if skip_or_break == "continue":
Expand Down
1 change: 1 addition & 0 deletions cl/corpus_importer/management/commands/update_scdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- votes_majority & votes_minority
- decision_direction
"""

import csv
import string
from datetime import datetime
Expand Down
1 change: 1 addition & 0 deletions cl/corpus_importer/task_canvases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This should help us organize the kinds of things we routinely do.
"""

from celery import chain
from django.contrib.auth.models import User

Expand Down
8 changes: 5 additions & 3 deletions cl/disclosures/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,11 @@ def save_disclosure(extracted_data: dict, disclosure) -> None:
redacted=any(v["is_redacted"] for v in debt.values()),
creditor_name=debt["Creditor"]["text"],
description=debt["Description"]["text"],
value_code=debt["Value Code"]["text"]
if debt["Value Code"]["text"] != "None"
else "",
value_code=(
debt["Value Code"]["text"]
if debt["Value Code"]["text"] != "None"
else ""
),
)
for debt in extracted_data["sections"]["Liabilities"]["rows"]
]
Expand Down
6 changes: 3 additions & 3 deletions cl/donate/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class Meta:

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields[
"wants_newsletter"
].label = "Send me the monthly Free Law Project newsletter"
self.fields["wants_newsletter"].label = (
"Send me the monthly Free Law Project newsletter"
)
for key in ["address1", "city", "state", "zip_code"]:
self.fields[key].required = True

Expand Down
2 changes: 0 additions & 2 deletions cl/lasc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ class Meta:


class Party(AbstractDateTimeModel):

"""
# "EntityNumber": "3",
# "PartyFlag": "L",
Expand Down Expand Up @@ -633,7 +632,6 @@ def get_queryset(self):


class Proceeding(AbstractDateTimeModel):

"""
"ProceedingDateString": "08/24/2018",
"CourtAlt": "",
Expand Down
6 changes: 3 additions & 3 deletions cl/lib/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def process_template_response(
if response.context_data:
private = response.context_data.get("private", False)
if private:
response.headers[
"X-Robots-Tag"
] = "noindex, noarchive, noimageindex"
response.headers["X-Robots-Tag"] = (
"noindex, noarchive, noimageindex"
)
return response
10 changes: 5 additions & 5 deletions cl/lib/search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,11 +980,11 @@ async def add_depth_counts(
return None
else:
for result in search_results.object_list:
result[
"citation_depth"
] = await get_citation_depth_between_clusters(
citing_cluster_pk=result["cluster_id"],
cited_cluster_pk=cited_cluster.pk,
result["citation_depth"] = (
await get_citation_depth_between_clusters(
citing_cluster_pk=result["cluster_id"],
cited_cluster_pk=cited_cluster.pk,
)
)
return cited_cluster
else:
Expand Down
12 changes: 6 additions & 6 deletions cl/lib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ class ApiPositionMapping(BasePositionMapping):
date_referred_to_judicial_committee_dict: defaultdict[
int, list[datetime]
] = field(default_factory=lambda: defaultdict(list))
date_judicial_committee_action_dict: defaultdict[
int, list[datetime]
] = field(default_factory=lambda: defaultdict(list))
date_judicial_committee_action_dict: defaultdict[int, list[datetime]] = (
field(default_factory=lambda: defaultdict(list))
)
date_hearing_dict: defaultdict[int, list[datetime]] = field(
default_factory=lambda: defaultdict(list)
)
Expand All @@ -228,9 +228,9 @@ class ApiPositionMapping(BasePositionMapping):
date_termination_dict: defaultdict[int, list[datetime]] = field(
default_factory=lambda: defaultdict(list)
)
date_granularity_termination_dict: defaultdict[
int, list[datetime]
] = field(default_factory=lambda: defaultdict(list))
date_granularity_termination_dict: defaultdict[int, list[datetime]] = (
field(default_factory=lambda: defaultdict(list))
)

judicial_committee_action_dict: defaultdict[int, list[str]] = field(
default_factory=lambda: defaultdict(list)
Expand Down
12 changes: 6 additions & 6 deletions cl/opinion_page/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,11 @@ async def make_rd_title(rd: RECAPDocument) -> str:
return "{desc}#{doc_num}{att_num} in {case_name} ({court}{docket_number})".format(
desc=f"{rd.description} – " if rd.description else "",
doc_num=rd.document_number,
att_num=f", Att. #{rd.attachment_number}"
if rd.document_type == RECAPDocument.ATTACHMENT
else "",
att_num=(
f", Att. #{rd.attachment_number}"
if rd.document_type == RECAPDocument.ATTACHMENT
else ""
),
case_name=best_case_name(d),
court=court.citation_string,
docket_number=f", {d.docket_number}" if d.docket_number else "",
Expand Down Expand Up @@ -1283,9 +1285,7 @@ async def block_item(request: HttpRequest) -> HttpResponse:
docket_pk = (
pk
if obj_type == "docket"
else cluster.docket_id
if cluster is not None
else None
else cluster.docket_id if cluster is not None else None
)
if not docket_pk:
return HttpResponse("It worked")
Expand Down
1 change: 1 addition & 0 deletions cl/people_db/import_judges/judge_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: elliott
"""

import re
from collections import Counter
from datetime import date, datetime
Expand Down
28 changes: 17 additions & 11 deletions cl/people_db/import_judges/populate_fjc_judges.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def transform_employ(string):
string_list = re.split("<BR>|;|<br>", string)
# Separate dates from the rest.
employ_list = [
[a]
if a is None or a.startswith("Nominated")
else re.split(r"\,+\s+(?=\d)+|\,+\s+(?=\-)", a, 1)
(
[a]
if a is None or a.startswith("Nominated")
else re.split(r"\,+\s+(?=\d)+|\,+\s+(?=\-)", a, 1)
)
for a in string_list
]

Expand Down Expand Up @@ -138,14 +140,18 @@ def transform_bankruptcy(string):
string_list = str(string)
string_list = re.split("<BR>|;|<br>", string_list)
bankruptcy_list = [
None
if a is None
else re.split(r"\,+\s+(?=\d)+", a, 1)
if not any(month in a for month in month_list)
else re.split(
r",+\s+(?=June|March|January|February|April|May|July|August|September|October|November|December|Fall|Spring)+",
a,
1,
(
None
if a is None
else (
re.split(r"\,+\s+(?=\d)+", a, 1)
if not any(month in a for month in month_list)
else re.split(
r",+\s+(?=June|March|January|February|April|May|July|August|September|October|November|December|Fall|Spring)+",
a,
1,
)
)
)
for a in string_list
]
Expand Down
1 change: 1 addition & 0 deletions cl/scrapers/management/commands/clone_from_cl.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
This is still work in progress, some data is not cloned yet.
"""

import json
import os
import pathlib
Expand Down
Loading

0 comments on commit c8b0257

Please sign in to comment.