88
99from __future__ import annotations
1010
11- from typing import Callable
11+ from typing import Any , Callable
1212
1313from archunitpython .common .assertion .violation import Violation
1414from archunitpython .common .fluentapi .checkable import CheckOptions
@@ -155,7 +155,7 @@ def functions(self) -> "FileMetricThresholdBuilder":
155155
156156
157157class ClassMetricThresholdBuilder :
158- def __init__ (self , project_path , filters , metric ) -> None :
158+ def __init__ (self , project_path : str | None , filters : list [ Filter ] , metric : Any ) -> None :
159159 self ._project_path = project_path
160160 self ._filters = filters
161161 self ._metric = metric
@@ -189,12 +189,19 @@ def should_be_above_or_equal(self, threshold: float) -> "ClassMetricCondition":
189189class ClassMetricCondition :
190190 """Checkable that verifies a class-level metric threshold."""
191191
192- def __init__ (self , project_path , filters , metric , threshold , comparison ) -> None :
192+ def __init__ (
193+ self ,
194+ project_path : str | None ,
195+ filters : list [Filter ],
196+ metric : Any ,
197+ threshold : float ,
198+ comparison : MetricComparison ,
199+ ) -> None :
193200 self ._project_path = project_path
194201 self ._filters = filters
195202 self ._metric = metric
196203 self ._threshold = threshold
197- self ._comparison : MetricComparison = comparison
204+ self ._comparison = comparison
198205
199206 def check (self , options : CheckOptions | None = None ) -> list [Violation ]:
200207 classes = _get_filtered_classes (self ._project_path , self ._filters )
@@ -218,7 +225,7 @@ def check(self, options: CheckOptions | None = None) -> list[Violation]:
218225
219226
220227class FileMetricThresholdBuilder :
221- def __init__ (self , project_path , filters , metric ) -> None :
228+ def __init__ (self , project_path : str | None , filters : list [ Filter ] , metric : Any ) -> None :
222229 self ._project_path = project_path
223230 self ._filters = filters
224231 self ._metric = metric
@@ -242,7 +249,14 @@ def should_be_below_or_equal(self, threshold: float) -> "FileMetricCondition":
242249class FileMetricCondition :
243250 """Checkable that verifies a file-level metric threshold."""
244251
245- def __init__ (self , project_path , filters , metric , threshold , comparison ) -> None :
252+ def __init__ (
253+ self ,
254+ project_path : str | None ,
255+ filters : list [Filter ],
256+ metric : Any ,
257+ threshold : float ,
258+ comparison : MetricComparison ,
259+ ) -> None :
246260 self ._project_path = project_path
247261 self ._filters = filters
248262 self ._metric = metric
@@ -288,7 +302,7 @@ def check(self, options: CheckOptions | None = None) -> list[Violation]:
288302
289303
290304class LCOMMetricsBuilder :
291- def __init__ (self , project_path , filters ) -> None :
305+ def __init__ (self , project_path : str | None , filters : list [ Filter ] ) -> None :
292306 self ._project_path = project_path
293307 self ._filters = filters
294308
@@ -321,7 +335,7 @@ def lcomstar(self) -> "ClassMetricThresholdBuilder":
321335
322336
323337class DistanceMetricsBuilder :
324- def __init__ (self , project_path , filters ) -> None :
338+ def __init__ (self , project_path : str | None , filters : list [ Filter ] ) -> None :
325339 self ._project_path = project_path
326340 self ._filters = filters
327341
@@ -348,7 +362,7 @@ def not_in_zone_of_uselessness(self) -> "ZoneCondition":
348362
349363
350364class DistanceThresholdBuilder :
351- def __init__ (self , project_path , filters , metric_attr ) -> None :
365+ def __init__ (self , project_path : str | None , filters : list [ Filter ] , metric_attr : str ) -> None :
352366 self ._project_path = project_path
353367 self ._filters = filters
354368 self ._metric_attr = metric_attr
@@ -375,7 +389,14 @@ def should_be_above(self, threshold: float) -> "DistanceCondition":
375389class DistanceCondition :
376390 """Checkable for distance metric thresholds."""
377391
378- def __init__ (self , project_path , filters , metric_attr , threshold , comparison ) -> None :
392+ def __init__ (
393+ self ,
394+ project_path : str | None ,
395+ filters : list [Filter ],
396+ metric_attr : str ,
397+ threshold : float ,
398+ comparison : MetricComparison ,
399+ ) -> None :
379400 self ._project_path = project_path
380401 self ._filters = filters
381402 self ._metric_attr = metric_attr
@@ -408,7 +429,7 @@ def check(self, options: CheckOptions | None = None) -> list[Violation]:
408429class ZoneCondition :
409430 """Checkable for zone detection (pain/uselessness)."""
410431
411- def __init__ (self , project_path , filters , zone_type ) -> None :
432+ def __init__ (self , project_path : str | None , filters : list [ Filter ] , zone_type : str ) -> None :
412433 self ._project_path = project_path
413434 self ._filters = filters
414435 self ._zone_type = zone_type
@@ -444,7 +465,14 @@ def check(self, options: CheckOptions | None = None) -> list[Violation]:
444465
445466
446467class CustomMetricsBuilder :
447- def __init__ (self , project_path , filters , name , description , calculation ) -> None :
468+ def __init__ (
469+ self ,
470+ project_path : str | None ,
471+ filters : list [Filter ],
472+ name : str ,
473+ description : str ,
474+ calculation : Callable [[ClassInfo ], float ],
475+ ) -> None :
448476 self ._project_path = project_path
449477 self ._filters = filters
450478 self ._name = name
@@ -486,13 +514,21 @@ def should_satisfy(
486514class CustomMetricCondition :
487515 """Checkable for custom metric thresholds."""
488516
489- def __init__ (self , project_path , filters , name , calculation , threshold , comparison ) -> None :
517+ def __init__ (
518+ self ,
519+ project_path : str | None ,
520+ filters : list [Filter ],
521+ name : str ,
522+ calculation : Callable [[ClassInfo ], float ],
523+ threshold : float ,
524+ comparison : MetricComparison ,
525+ ) -> None :
490526 self ._project_path = project_path
491527 self ._filters = filters
492528 self ._name = name
493529 self ._calculation = calculation
494530 self ._threshold = threshold
495- self ._comparison : MetricComparison = comparison
531+ self ._comparison = comparison
496532
497533 def check (self , options : CheckOptions | None = None ) -> list [Violation ]:
498534 classes = _get_filtered_classes (self ._project_path , self ._filters )
@@ -518,7 +554,14 @@ def check(self, options: CheckOptions | None = None) -> list[Violation]:
518554class CustomAssertionCondition :
519555 """Checkable for custom metric assertions."""
520556
521- def __init__ (self , project_path , filters , name , calculation , assertion ) -> None :
557+ def __init__ (
558+ self ,
559+ project_path : str | None ,
560+ filters : list [Filter ],
561+ name : str ,
562+ calculation : Callable [[ClassInfo ], float ],
563+ assertion : Callable [[float , ClassInfo ], bool ],
564+ ) -> None :
522565 self ._project_path = project_path
523566 self ._filters = filters
524567 self ._name = name
0 commit comments