Baracchino-Della-Scuola / Bot

Unnecessary use of json.dumps() for file data PY-W0079
Anti-pattern
Major
4 months ago2 years old
f.write(json.dumps(jsonf)) can be replaced with json.dump(jsonf, f)
 28        f.close()
 29        jsonf[key] = value
 30        f = open("settings.json", "w")
 31        f.write(json.dumps(jsonf)) 32        await ctx.send("updated settings")
 33
 34    @commands.command(
fil.write(json.dumps(cor_articles)) can be replaced with json.dump(cor_articles, fil)
66            print("oof")
67
68            cor_articles.append(cor.title)
69            fil.write(json.dumps(cor_articles))70            fil.close()
71            ch = self.bot.get_channel(946354506214539315)
72
fil.write(json.dumps(self.articles)) can be replaced with json.dump(self.articles, fil)
59        fil = open("corriere.json", "w")
60        if cor.title in cor_articles:
61            print("exists")
62            fil.write(json.dumps(self.articles))63            fil.close()
64
65        else:
fil.write(json.dumps(self.articles)) can be replaced with json.dump(self.articles, fil)
35
36        self.articles.append(entry["title"])
37
38        fil.write(json.dumps(self.articles))39        print("closing...")
40        fil.close()
41
fil.write(json.dumps(self.articles)) can be replaced with json.dump(self.articles, fil)
25        entry = feed.entries[0]
26
27        if entry["title"] in self.articles:
28            fil.write(json.dumps(self.articles))29            fil.close()
30            return
31        print("oof")