Skip to content

Commit

Permalink
feat(Court): make it clearer what Court.ncn actually means
Browse files Browse the repository at this point in the history
`Court.ncn` is now `Court.ncn_pattern`, and is explicitly typed as being a subtype of a regular expression pattern. This is because it looked very similar to representing a Neutral Citation (ie the NCN of an individual judgment), and not (as it actually case) representing the pattern which valid NCNs for that court must match.

BREAKING CHANGE: `Court.ncn` is now `Court.ncn_pattern`, and now returns a `NeutralCitationPattern` which is a subtype of `re.Pattern[str]`.
  • Loading branch information
jacksonj04 committed Oct 2, 2024
1 parent 30a5edc commit 47f650d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 53 deletions.
11 changes: 7 additions & 4 deletions src/ds_caselaw_utils/courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pathlib
from datetime import date
from re import compile
from typing import Optional

from ruamel.yaml import YAML
Expand All @@ -16,7 +17,7 @@
RawJurisdiction,
)

from .types import CourtCode, CourtParam, JurisdictionCode, NeutralCitationString
from .types import CourtCode, CourtParam, JurisdictionCode, NeutralCitationPattern


class Jurisdiction:
Expand All @@ -34,7 +35,9 @@ def __init__(self, data: RawCourt) -> None:
self.name: str = data["name"]
self.grouped_name: str = data.get("grouped_name") or data["name"]
self.link: str = data["link"]
self.ncn: Optional[NeutralCitationString] = NeutralCitationString(data["ncn"]) if "ncn" in data else None
self.ncn_pattern: Optional[NeutralCitationPattern] = (
NeutralCitationPattern(compile(data["ncn_pattern"])) if "ncn_pattern" in data else None
)
if "param" in data:
self.canonical_param = CourtParam(data["param"])
self.param_aliases = [CourtParam(data["param"])] + [
Expand Down Expand Up @@ -83,8 +86,8 @@ def link(self) -> str:
return self.court.link

@property
def ncn(self) -> Optional[NeutralCitationString]:
return self.court.ncn
def ncn_pattern(self) -> Optional[NeutralCitationPattern]:
return self.court.ncn_pattern

@property
def canonical_param(self) -> Optional[CourtParam]:
Expand Down
Loading

0 comments on commit 47f650d

Please sign in to comment.