Skip to content

Support Python 3.11 and earlier in authentication file error handling #1056

Description

@mmguero

Description

The authentication file validation code introduced in 26.07.0 for #865 (see mmguero-dev@954daf7) introduced a multiline expression inside a single-quoted f-string:

missingAuthMessage = f'Files relating to authentication and/or secrets are missing: {", ".join([
    p[len(malcolmPathPrefix) :] if p.startswith(malcolmPathPrefix) else p for p in missingAuthFiles
])}; please run ./scripts/auth_setup to generate them'

This syntax works with Python 3.12 and later due to the updated f-string grammar introduced by PEP 701.

On Python 3.11 and earlier, however, the script fails to parse with:

SyntaxError: unterminated string literal

This prevents commands such as start, wipe, and logs from running on systems using an older supported Python version.

Fix

Build the comma-separated file list separately, then interpolate the resulting string into the error message:

missingAuthFileList = ", ".join(
    p[len(malcolmPathPrefix) :]
    if p.startswith(malcolmPathPrefix)
    else p
    for p in missingAuthFiles
)

missingAuthMessage = (
    "Files relating to authentication and/or secrets are missing: "
    f"{missingAuthFileList}; please run ./scripts/auth_setup to generate them"
)

This preserves the existing behavior while remaining compatible with Python 3.11 and newer.

See idaholab@b1d0700 for the fix.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcontrol.pyRelated to control.py scriptregressionIt worked at one point...

Type

Fields

Frequency

None yet

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions