Skip to content

Commit

Permalink
WIP: add some typing
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonj04 committed Sep 26, 2024
1 parent 360f6df commit 30765e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/ds_caselaw_utils/courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@


class Jurisdiction:
def __init__(self, data):
def __init__(self, data) -> None:
self.code = data.get("code")
self.name = data.get("name")
self.prefix = data.get("prefix")


class Court:
def __init__(self, data):
def __init__(self, data) -> None:
self.code = data.get("code")
self.name = data.get("name")
self.grouped_name = data.get("grouped_name") or data.get("name")
Expand All @@ -34,12 +34,12 @@ def get_jurisdiction(self, code):
def expand_jurisdictions(self):
return [self] + [CourtWithJurisdiction(self, jurisdiction) for jurisdiction in self.jurisdictions]

def __repr__(self):
def __repr__(self) -> str:
return self.name


class CourtWithJurisdiction(Court):
def __init__(self, court, jurisdiction):
def __init__(self, court, jurisdiction) -> None:
self.court = court
self.jurisdiction = jurisdiction
self.jurisdictions = []
Expand All @@ -49,11 +49,11 @@ def code(self):
return "/".join((self.court.code, self.jurisdiction.code))

@property
def name(self):
def name(self) -> str:
return "%s – %s" % (self.court.name, self.jurisdiction.name)

@property
def grouped_name(self):
def grouped_name(self) -> str:
return self.court.grouped_name

@property
Expand All @@ -73,11 +73,11 @@ def param_aliases(self):
return self.court.param_aliases

@property
def start_year(self):
def start_year(self) -> int:
return self.court.start_year

@property
def end_year(self):
def end_year(self) -> int:
return self.court.end_year

@property
Expand All @@ -86,12 +86,12 @@ def jurisdiction_prefix(self):


class CourtGroup:
def __init__(self, name, courts):
def __init__(self, name, courts) -> None:
self.name = name
self.courts = courts

@property
def display_heading(self):
def display_heading(self) -> str:
return self.name is not None


Expand All @@ -100,7 +100,7 @@ class CourtNotFoundException(Exception):


class CourtsRepository:
def __init__(self, data):
def __init__(self, data) -> None:
self._data = data
self._byParam = {}
self._byCode = {}
Expand Down
3 changes: 2 additions & 1 deletion src/ds_caselaw_utils/neutral.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pathlib
import re
from typing import Optional

from ruamel.yaml import YAML

Expand All @@ -13,7 +14,7 @@
citation_data = yaml.load(f)


def neutral_url(citation):
def neutral_url(citation:str) -> Optional[str]:
"""Given a neutral citation such as `[2020] EAT 17`,
return a public-API URL like `/eat/2020/17`, or None
if no match is found.
Expand Down

0 comments on commit 30765e5

Please sign in to comment.