Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(courts): add additional type statements for stricter behaviour of courts repository #189

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/ds_caselaw_utils/courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class Jurisdiction:
def __init__(self, data: RawJurisdiction):
self.code: JurisdictionCode = JurisdictionCode(data["code"])
self.name = data["name"]
self.name: str = data["name"]
self.prefix: Optional[str] = data.get("prefix")


Expand Down Expand Up @@ -126,15 +126,15 @@ class CourtNotFoundException(Exception):

class CourtsRepository:
def __init__(self, data: RawCourtRepository):
self._data = data
self._byParam = {}
self._byCode = {}
self._data: RawCourtRepository = data
self._byParam: dict[CourtParam, Court] = {}
self._byCode: dict[CourtCode, Court] = {}
for group in self._data:
for courtData in group.get("courts", []):
court = Court(courtData)
if "param" in courtData:
self._byParam[courtData.get("param")] = court
self._byCode[courtData["code"]] = court
self._byParam[CourtParam(courtData["param"])] = court
self._byCode[CourtCode(courtData["code"])] = court

def get_by_param(self, param: CourtParam) -> Court:
try:
Expand Down