junepark678 / GIRRewrite

File opened without the with statement PTC-W0010
Anti-pattern
Critical
a year agoa year old
Use the with statement to open a file
1903            await self.respond(ctx.ctx, embed=self.queue_embed(data[args[0]], page, loc["messages"]["playlist_page_title"].format(args[0]), "", "id"))
1904        if not os.path.isdir("./music"):
1905            os.mkdir("./music")
1906        open(file, "w", encoding="utf-8").write(json.dumps(data))1907
1908    @bridge.bridge_command(name="musicversion", description=loc["descriptions"]["musicversion"])
1909    async def musicversion(self, ctx):
Use the with statement to open a file
1763    async def playlist_func(self, ctx, *, args=None):
1764        file = f"./music/playlist_{ctx.author.id}.json"
1765        if os.path.isfile(file):
1766            data = json.loads(open(file, "r", encoding="utf-8").read())1767        else:
1768            data = {}
1769        if args is None: