IzunaDevs / SnekChek

A tool that aims to combine all python CQA tools into one highly customizable tool
MIT License
4 stars 3 forks source link

Python<3.6 compat #1

Closed Martmists-GH closed 6 years ago

Martmists-GH commented 6 years ago

We're using a lot of f-strings, they should be reworked to str.format to support lower versions of python.

AraHaan commented 6 years ago

Maybe an shortcut function could do it, however then how would I substitute it for an f string if python >= 3.6?

import sys

def format_str(formatstr, *args):
    if sys.version_info < (3, 6):
        if args:
            return str.format(formatstr, args)
        else:
            return str.format(formatstr)
    else:
        # go to f string.
        return f"{formatstr}"

perhaps the only way is to figure out how to similate the f strings?

Martmists-GH commented 6 years ago

what the hell did you smoke

It's just gonna be "{}".format(...) instead of f"{}"

That code you provided will fail either way and won't even work...

AraHaan commented 6 years ago

Ah I see, I sorta forgot because of fstrings.