Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new Python 3.12 f-string syntax #126

Open
CarrotManMatt opened this issue Jan 2, 2024 · 0 comments
Open

Use new Python 3.12 f-string syntax #126

CarrotManMatt opened this issue Jan 2, 2024 · 0 comments
Labels
good first issue Good for newcomers refactor Improvements to the codebase that do not directly affect users

Comments

@CarrotManMatt
Copy link
Member

CarrotManMatt commented Jan 2, 2024

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.)

@CarrotManMatt CarrotManMatt added good first issue Good for newcomers refactor Improvements to the codebase that do not directly affect users labels Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers refactor Improvements to the codebase that do not directly affect users
Projects
None yet
Development

No branches or pull requests

1 participant