# \[Python S1481\] Unused local variables should be remove with f-string format

**URL:** <https://community.sonarsource.com/t/python-s1481-unused-local-variables-should-be-remove-with-f-string-format/36124>\
**Category:** SonarQube Cloud\
**Tags:** python\
**Created:** [December 21, 2020, 6:45am UTC](https://community.sonarsource.com/t/python-s1481-unused-local-variables-should-be-remove-with-f-string-format/36124 "2020-12-21T06:45:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wzmf399443](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/wzmf399443/32/17849_2.png) [@wzmf399443](https://community.sonarsource.com/u/wzmf399443)\
**Post date:** [December 21, 2020, 6:45am UTC](https://community.sonarsource.com/t/python-s1481-unused-local-variables-should-be-remove-with-f-string-format/36124/1 "2020-12-21T06:45:27Z")

</div>

- versions used  
Sonar Could for Azure DevOps pull request
- Code:

```auto
style = "style = 'background-color : pink;'"
#SonarCloud alert: Remove the unused local variable "style".
key_name = k.replace("_", "\\_")
#SonarCloud alert: Remove the unused local variable "key_name".
body_text += f'''<tr {style if Counter(v.values()).get('FAIL', 0) != 0 else ''}><td>{key_name}</td><td>{Counter(v.values()).get('PASS', 0)}</td><td>{Counter(v.values()).get('FAIL', 0)}</td></tr>'''

```

The variable “style” and “key\_name” are used in the f-string (body\_text) but still get this error and block the PR

---

<div class="post-metadata">

**Author:** ![Andrea\_Guarino](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andrea_guarino/32/54797_2.png) [@Andrea\_Guarino](https://community.sonarsource.com/u/Andrea_Guarino)\
**Post date:** [December 21, 2020, 8:14am UTC](https://community.sonarsource.com/t/python-s1481-unused-local-variables-should-be-remove-with-f-string-format/36124/2 "2020-12-21T08:14:05Z")

</div>

hello @wzmf399443,

welcome to our community!  
I’m able to reproduce the false positive you reported and I created ticket [SONARPY-815](https://jira.sonarsource.com/browse/SONARPY-815) to keep track of it.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [April 8, 2021, 8:45am UTC](https://community.sonarsource.com/t/python-s1481-unused-local-variables-should-be-remove-with-f-string-format/36124/3 "2021-04-08T08:45:56Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
