@@ -48,9 +48,9 @@ class Missing:
4848
4949
5050def validate_roles (
51- person : Person ,
52- roles_key : str ,
53- retired : bool = False ,
51+ person : Person ,
52+ roles_key : str ,
53+ retired : bool = False ,
5454) -> list [str ]:
5555 active = [role for role in getattr (person , roles_key ) if role .is_active ()]
5656 if len (active ) == 0 and not retired :
@@ -63,9 +63,10 @@ def validate_roles(
6363
6464
6565def validate_roles_key (
66- person : Person ,
67- person_type : PersonType ,
68- fix : bool ,
66+ person : Person ,
67+ person_type : PersonType ,
68+ fix : bool ,
69+ ignore_role_warnings : bool ,
6970) -> CheckResult :
7071 resp = CheckResult ([], [], [])
7172 role_issues = validate_roles (
@@ -80,7 +81,7 @@ def validate_roles_key(
8081 # municipals missing roles is a warning to avoid blocking lint
8182 if fix :
8283 resp .fixes = [MOVED_TO_RETIRED ]
83- else :
84+ elif not ignore_role_warnings :
8485 resp .warnings .extend (role_issues )
8586 else :
8687 resp .errors .extend (role_issues )
@@ -111,7 +112,7 @@ def validate_offices(person: Person) -> list[str]:
111112 return errors
112113
113114
114- def validate_name (person : Person , person_type : PersonType , fix : bool ) -> CheckResult :
115+ def validate_name (person : Person , person_type : PersonType , fix : bool , ignore_role_warnings : bool ) -> CheckResult :
115116 """some basic checks on a persons name"""
116117 errors = []
117118 fixes = []
@@ -155,7 +156,7 @@ def validate_jurisdictions(person: Person, municipalities: list[str]) -> list[st
155156
156157
157158def get_expected_districts (
158- settings : dict [str , dict ], abbr : str
159+ settings : dict [str , dict ], abbr : str
159160) -> _EXPECTED_DISTRICTS_TYPE :
160161 expected = {}
161162
@@ -194,7 +195,7 @@ def get_expected_districts(
194195
195196
196197def compare_districts (
197- expected : _EXPECTED_DISTRICTS_TYPE , actual : _ACTUAL_DISTRICTS_TYPE
198+ expected : _EXPECTED_DISTRICTS_TYPE , actual : _ACTUAL_DISTRICTS_TYPE
198199) -> list [str ]:
199200 errors = []
200201
@@ -222,9 +223,10 @@ def compare_districts(
222223
223224
224225class Validator :
225- def __init__ (self , abbr : str , settings : dict , fix : bool , save_all : bool ):
226+ def __init__ (self , abbr : str , settings : dict , fix : bool , save_all : bool , ignore_role_warnings : bool ):
226227 self .fix = fix
227228 self .save_all = save_all
229+ self .ignore_role_warnings = ignore_role_warnings
228230 self .expected = get_expected_districts (settings , abbr )
229231 self .errors : defaultdict [str , list [str ]] = defaultdict (list )
230232 self .warnings : defaultdict [str , list [str ]] = defaultdict (list )
@@ -244,24 +246,24 @@ def __init__(self, abbr: str, settings: dict, fix: bool, save_all: bool):
244246 raise ValueError (f"invalid municipality id { m } " )
245247
246248 def process_validator_result (
247- self ,
248- validator_func : typing .Callable [[Person , PersonType , bool ], CheckResult ],
249- person : Person ,
250- person_type : PersonType ,
251- original_filename : Path ,
249+ self ,
250+ validator_func : typing .Callable [[Person , PersonType , bool , bool ], CheckResult ],
251+ person : Person ,
252+ person_type : PersonType ,
253+ original_filename : Path ,
252254 ) -> None :
253- result = validator_func (person , person_type , self .fix )
255+ result = validator_func (person , person_type , self .fix , self . ignore_role_warnings )
254256 self .errors [original_filename .name ].extend (result .errors )
255257 self .warnings [original_filename .name ].extend (result .warnings )
256258 if result .fixes :
257259 self .fixes [original_filename .name ].extend (result .fixes )
258260 dump_obj (person , filename = original_filename )
259261
260262 def validate_person (
261- self ,
262- data : dict [str , typing .Any ],
263- filename : Path ,
264- person_type : PersonType ,
263+ self ,
264+ data : dict [str , typing .Any ],
265+ filename : Path ,
266+ person_type : PersonType ,
265267 ) -> None :
266268 print_filename = filename .name
267269 try :
@@ -326,9 +328,9 @@ def validate_old_district_names(self, person: Person) -> list[str]:
326328 errors = []
327329 for role in person .roles :
328330 if (
329- role .district
330- and role .district not in self .expected [role .type ]
331- and role .district not in self .legacy_districts [role .type ]
331+ role .district
332+ and role .district not in self .expected [role .type ]
333+ and role .district not in self .legacy_districts [role .type ]
332334 ):
333335 errors .append (f"unknown district name: { role .type } { role .district } " )
334336 return errors
0 commit comments