From b0937782a8b9b4b3f33d711e75136015435f8f74 Mon Sep 17 00:00:00 2001 From: db0 Date: Mon, 18 Sep 2023 12:55:38 +0200 Subject: [PATCH] fix: avoid clobbering instace var --- fediseer/apis/v1/censures.py | 24 ++++++++++++------------ fediseer/apis/v1/endorsements.py | 24 ++++++++++++------------ fediseer/apis/v1/hesitations.py | 25 ++++++++++++------------- 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/fediseer/apis/v1/censures.py b/fediseer/apis/v1/censures.py index a0d9423..9727d03 100644 --- a/fediseer/apis/v1/censures.py +++ b/fediseer/apis/v1/censures.py @@ -35,18 +35,18 @@ class CensuresGiven(Resource): if not precheck_instances: raise e.NotFound(f"No Instances found matching any of the provided domains. Have you remembered to register them?") instances = [] - for instance in precheck_instances: - if instance.visibility_censures == enums.ListVisibility.ENDORSED: + for p_instance in precheck_instances: + if p_instance.visibility_censures == enums.ListVisibility.ENDORSED: if get_instance is None: continue - if instance != get_instance and not instance.is_endorsing(get_instance): + if p_instance != get_instance and not p_instance.is_endorsing(get_instance): continue - if instance.visibility_censures == enums.ListVisibility.PRIVATE: + if p_instance.visibility_censures == enums.ListVisibility.PRIVATE: if get_instance is None: continue - if instance != get_instance: + if p_instance != get_instance: continue - instances.append(instance) + instances.append(p_instance) if len(instances) == 0: raise e.Forbidden(f"You do not have access to see these censures") if self.args.min_censures > len(instances): @@ -125,18 +125,18 @@ class Censures(Resource): instance_details = [] precheck_instances = database.get_all_censuring_instances_by_censured_id(instance.id) instances = [] - for instance in precheck_instances: - if instance.visibility_censures == enums.ListVisibility.ENDORSED: + for p_instance in precheck_instances: + if p_instance.visibility_censures == enums.ListVisibility.ENDORSED: if get_instance is None: continue - if not instance.is_endorsing(get_instance): + if not p_instance.is_endorsing(get_instance): continue - if instance.visibility_censures == enums.ListVisibility.PRIVATE: + if p_instance.visibility_censures == enums.ListVisibility.PRIVATE: if get_instance is None: continue - if not instance != get_instance: + if not p_instance != get_instance: continue - instances.append(instance) + instances.append(p_instance) for c_instance in instances: censures = database.get_all_censure_reasons_for_censured_id(instance.id, [c_instance.id]) censures = [c for c in censures if c.reason is not None] diff --git a/fediseer/apis/v1/endorsements.py b/fediseer/apis/v1/endorsements.py index d1db63a..5c51cd9 100644 --- a/fediseer/apis/v1/endorsements.py +++ b/fediseer/apis/v1/endorsements.py @@ -35,18 +35,18 @@ class Approvals(Resource): if not precheck_instances: raise e.NotFound(f"No Instances found matching any of the provided domains. Have you remembered to register them?") instances = [] - for instance in precheck_instances: - if instance.visibility_endorsements == enums.ListVisibility.ENDORSED: + for p_instance in precheck_instances: + if p_instance.visibility_endorsements == enums.ListVisibility.ENDORSED: if get_instance is None: continue - if instance != get_instance and not instance.is_endorsing(get_instance): + if p_instance != get_instance and not p_instance.is_endorsing(get_instance): continue - if instance.visibility_endorsements == enums.ListVisibility.PRIVATE: + if p_instance.visibility_endorsements == enums.ListVisibility.PRIVATE: if get_instance is None: continue - if instance != get_instance: + if p_instance != get_instance: continue - instances.append(instance) + instances.append(p_instance) if len(instances) == 0: raise e.Forbidden(f"You do not have access to see these endorsements") instance_details = [] @@ -105,18 +105,18 @@ class Endorsements(Resource): instance_details = [] precheck_instances = database.get_all_approving_instances_by_endorsed_id(instance.id) instances = [] - for instance in precheck_instances: - if instance.visibility_endorsements == enums.ListVisibility.ENDORSED: + for p_instance in precheck_instances: + if p_instance.visibility_endorsements == enums.ListVisibility.ENDORSED: if get_instance is None: continue - if not instance.is_endorsing(get_instance): + if not p_instance.is_endorsing(get_instance): continue - if instance.visibility_endorsements == enums.ListVisibility.PRIVATE: + if p_instance.visibility_endorsements == enums.ListVisibility.PRIVATE: if get_instance is None: continue - if not instance != get_instance: + if not p_instance != get_instance: continue - instances.append(instance) + instances.append(p_instance) for e_instance in instances: endorsements = database.get_all_endorsement_reasons_for_endorsed_id(instance.id, [e_instance.id]) endorsements = [e for e in endorsements if e.reason is not None] diff --git a/fediseer/apis/v1/hesitations.py b/fediseer/apis/v1/hesitations.py index cce6b8e..3cf0f28 100644 --- a/fediseer/apis/v1/hesitations.py +++ b/fediseer/apis/v1/hesitations.py @@ -35,19 +35,18 @@ class HesitationsGiven(Resource): if not precheck_instances: raise e.NotFound(f"No Instances found matching any of the provided domains. Have you remembered to register them?") instances = [] - for instance in precheck_instances: - if instance.visibility_hesitations == enums.ListVisibility.ENDORSED: + for p_instance in precheck_instances: + if p_instance.visibility_hesitations == enums.ListVisibility.ENDORSED: if get_instance is None: continue - if instance != get_instance and not instance.is_endorsing(get_instance): + if p_instance != get_instance and not p_instance.is_endorsing(get_instance): continue - if instance.visibility_hesitations == enums.ListVisibility.PRIVATE: - logger.debug([instance.visibility_hesitations,instance,get_instance,instance != get_instance]) + if p_instance.visibility_hesitations == enums.ListVisibility.PRIVATE: if get_instance is None: continue - if instance != get_instance: + if p_instance != get_instance: continue - instances.append(instance) + instances.append(p_instance) if len(instances) == 0: raise e.Forbidden(f"You do not have access to see these hesitations") if self.args.min_hesitations > len(instances): @@ -110,18 +109,18 @@ class Hesitations(Resource): raise e.NotFound(f"No Instance found matching provided domain. Have you remembered to register it?") precheck_instances = database.get_all_hesitant_instances_by_dubious_id(instance.id) instances = [] - for instance in precheck_instances: - if instance.visibility_endorsements == enums.ListVisibility.ENDORSED: + for p_instance in precheck_instances: + if p_instance.visibility_endorsements == enums.ListVisibility.ENDORSED: if get_instance is None: continue - if not instance.is_endorsing(get_instance): + if not p_instance.is_endorsing(get_instance): continue - if instance.visibility_endorsements == enums.ListVisibility.PRIVATE: + if p_instance.visibility_endorsements == enums.ListVisibility.PRIVATE: if get_instance is None: continue - if not instance != get_instance: + if not p_instance != get_instance: continue - instances.append(instance) + instances.append(p_instance) instance_details = [] for c_instance in instances: hesitations = database.get_all_hesitation_reasons_for_dubious_id(instance.id, [c_instance.id])