make sure to add all constraint types to return

This commit is contained in:
Joshua Burman 2023-11-12 18:37:29 -05:00
parent f1fa519f31
commit eb8138eaf9

View File

@ -69,7 +69,7 @@ class SolverRun(BaseModel):
if bundle.id == bundle_id: if bundle.id == bundle_id:
return bundle return bundle
def get_constraint_by_type(self, type: str) -> Constraint or None: def get_constraint_by_type(self, type: str) -> GenericConstraint|MetadataConstraint|BundleConstraint|FormUniquenessConstraint|TotalFormItemsConstraint or None:
for constraint in self.constraints: for constraint in self.constraints:
if type == constraint.reference_attribute.type: if type == constraint.reference_attribute.type:
return constraint return constraint
@ -130,7 +130,7 @@ class SolverRun(BaseModel):
logging.info('Bundles Generated...') logging.info('Bundles Generated...')
def get_constraint(self, name: str) -> Constraint: def get_constraint(self, name: str) -> GenericConstraint|MetadataConstraint|BundleConstraint|FormUniquenessConstraint|TotalFormItemsConstraint:
return next((constraint for constraint in self.constraints return next((constraint for constraint in self.constraints
if constraint.reference_attribute.id == name), None) if constraint.reference_attribute.id == name), None)