Baracchino-Della-Scuola / Bot

Unnecessary use of json.loads() for file data PY-W0078
Anti-pattern
Major
4 months ago2 years old
json.loads(f.read()) can be replaced with json.load(f)
 24    @commands.command()
 25    async def settings(self, ctx, key, value):
 26        f = open("settings.json", "r")
 27        jsonf = json.loads(f.read()) 28        f.close()
 29        jsonf[key] = value
 30        f = open("settings.json", "w")
json.loads(session.read()) can be replaced with json.load(session)
52        print("a")
53        session = open("corriere.json ", "r")
54
55        cor_articles = json.loads(session.read())56        session.close()
57        print("corriere")
58        print(cor.title in cor_articles)
json.loads(ses.read()) can be replaced with json.load(ses)
 8        self.rss_url = "https://www.repubblica.it/rss/esteri/rss2.0.xml"
 9        self.corriere_url = "http://xml2.corriereobjects.it/rss/esteri.xml"
10        ses = open("articles.json", "r")
11        self.articles = json.loads(ses.read())12        ses.close()
13        self.send_announcements.start()
14        self.send_announcements_corriere.start()