berrysauce / ingredients

Unnecessary use of json.loads() for file data PY-W0078
Anti-pattern
Major
4 months ago4 months old
json.loads(f.read()) can be replaced with json.load(f)
132        
133        if includeCategories:
134            with open("ingredients/categories.json", "r") as f:
135                return_data["categories"] = json.loads(f.read())136        
137        # ----- CACHE -----
138        # add data to cache
json.loads(f.read()) can be replaced with json.load(f)
102            for ingredient in matching_ingredients:
103                if ingredient.split("/")[0] == category:
104                    with open(f"ingredients/{ingredient}", "r") as f:
105                        ingredient_data = json.loads(f.read())106                        
107                    ingredient_name = ingredient.split("/")[1].replace(".json", "")
108                        
json.loads(f.read()) can be replaced with json.load(f)
 46        
 47        for ingredient in ingredients:
 48            with open(f"ingredients/{category}/{ingredient}", "r") as f:
 49                ingredient_data = json.loads(f.read()) 50            
 51            
 52            # ----- STATS -----