Home > Net >  C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
C0209: Formatting a regular string which could be a f-string (consider-using-f-string)

Time:08-12

For the below line, I am getting pylint issue: " C0209: Formatting a regular string which could be a f-string (consider-using-f-string)"

auth = str(base64.b64encode(bytes("%s:%s" % (self.user, self.password), "utf-8")), "ascii").strip()

I tried resolving it, but I am not sure if it is the right way to fix it. Can someone please advise?

auth = str(base64.b64encode(bytes(f'{self.user, self.password}', "utf-8")), "ascii").strip()

CodePudding user response:

auth = str(base64.b64encode(bytes(f'{self.user}:{self.password}', "utf-8")), "ascii").strip()

You may not be using the f-string correctly, change f'{self.user, self.password}' to f'{self.user}:{self.password}'

More info

  • Related