Skip to content

fix: f-string expression part cannot include a backslash#18

Merged
HackTestes merged 1 commit into
HackTestes:masterfrom
Daniel-Aaron-Bloom:patch-1
Sep 21, 2025
Merged

fix: f-string expression part cannot include a backslash#18
HackTestes merged 1 commit into
HackTestes:masterfrom
Daniel-Aaron-Bloom:patch-1

Conversation

@Daniel-Aaron-Bloom
Copy link
Copy Markdown
Contributor

f-string and string concat is redundant and \n causes issues on older versions of python (I'm getting this on Python 3.13.5).

Traceback (most recent call last):
  File "/root/.local/bin/chnvml", line 3, in <module>
    from caioh_nvml_gpu_control.__main__ import script_call
  File "/root/.local/pipx/venvs/caioh-nvml-gpu-control/lib/python3.11/site-packages/caioh_nvml_gpu_control/__main__.py", line 9, in <module>
    import nvml_gpu_control
  File "/root/.local/pipx/venvs/caioh-nvml-gpu-control/lib/python3.11/site-packages/caioh_nvml_gpu_control/nvml_gpu_control.py", line 3, in <module>
    import helper_functions as main_funcs
  File "/root/.local/pipx/venvs/caioh-nvml-gpu-control/lib/python3.11/site-packages/caioh_nvml_gpu_control/helper_functions.py", line 261
    log_helper(f'{"\n" + "\n".join(log_msg) + "\n"}')
                                                    ^
SyntaxError: f-string expression part cannot include a backslash

f-string and string concat is redundant and `\n` causes issues on older versions of python (I'm getting this on Python 3.13.5).

```
Traceback (most recent call last):
  File "/root/.local/bin/chnvml", line 3, in <module>
    from caioh_nvml_gpu_control.__main__ import script_call
  File "/root/.local/pipx/venvs/caioh-nvml-gpu-control/lib/python3.11/site-packages/caioh_nvml_gpu_control/__main__.py", line 9, in <module>
    import nvml_gpu_control
  File "/root/.local/pipx/venvs/caioh-nvml-gpu-control/lib/python3.11/site-packages/caioh_nvml_gpu_control/nvml_gpu_control.py", line 3, in <module>
    import helper_functions as main_funcs
  File "/root/.local/pipx/venvs/caioh-nvml-gpu-control/lib/python3.11/site-packages/caioh_nvml_gpu_control/helper_functions.py", line 261
    log_helper(f'{"\n" + "\n".join(log_msg) + "\n"}')
                                                    ^
SyntaxError: f-string expression part cannot include a backslash
```
@HackTestes
Copy link
Copy Markdown
Owner

I would like to start by saying that I appreciate when someone takes a look at the code and I like it even more when they already provide the fixes for the problems. So, huge thanks!

The fix is rather simple and I will accept it, but first I will test it locally to see if nothing breaks unexpectedly. It also makes the code more readable (I don't know I made the code like that to be honest with you).

I'm getting this on Python 3.13.5

Well, that is interesting. I have just checked my python version (just to see why I didn't get the error) and I am actually using an older version of python (Python 3.13.1). Anyways, I will just test and implement your fix.

To finish, thanks for contributing!

@HackTestes HackTestes merged commit f9368c0 into HackTestes:master Sep 21, 2025
@HackTestes
Copy link
Copy Markdown
Owner

It took me a while to be able to stop and test the code, but I finally got the time. The code did not break anything and was merged into the main branch.

I will do some other small updates and release a new version on Pypi.

Once again, thanks for the contribution!

@Daniel-Aaron-Bloom Daniel-Aaron-Bloom deleted the patch-1 branch September 22, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants