CSSUoB / TeX-Bot-Py-V2

TeX-Bot, but back in Python! (V2)
Apache License 2.0
2 stars 6 forks source link

Use new Python 3.12 f-string syntax #126

Open CarrotManMatt opened 9 months ago

CarrotManMatt commented 9 months ago

Now that we have updated this project to use Python 3.12 (#124), all multi-line f-strings should be updated to use the new syntax.

For example:

my_var: str = (
    f"""This is a {
        random.choice("good", "amazing", "wonderful")
    }. My next random number will be provided below in due course: {
        random.choice(
            999_999_999_999_999,
            420,
            10,
            0
        )
        if random.randint(0, 101) == 69
        else random.random()
    }"""
)

Would be changed to:

my_var: str = (
    f"This is a {random.choice("good", "amazing", "wonderful")}. "
    "My next random number will be provided below in due course: "
    f"{
        random.choice(
            999_999_999_999_999,
            420,
            10,
            0
        )
        if random.randint(0, 101) == 69
        else random.random()
    }"
)

(I am aware that this example can be simplified on to a single line without the line-length being exceeded, however this is just an example. Use the shown changes to help when the changed lines do exceed the maximum allowed line-length.)

ashprit-x commented 3 months ago

Can you assign me this please & also what part of the code would i need to refactor? (I assume it will be all of it?)

MattyTheHacker commented 3 months ago

scope wise yeah I assume the entire code base but @CarrotManMatt may have other thoughts

CarrotManMatt commented 3 months ago

Yup, everything! Admittedly I think we've slowly eroded a lot of it (esp since ruff complains about some bits). But would just be good to get you to have a formal look over every line to know for certain there's none left

ashprit-x commented 3 months ago

Alright I will start working on it, thanks!