# False positive for python:S6546

**URL:** <https://community.sonarsource.com/t/false-positive-for-python-s6546/179644>\
**Category:** Report False-positive / False-negative...\
**Created:** [March 16, 2026, 9:28am UTC](https://community.sonarsource.com/t/false-positive-for-python-s6546/179644 "2026-03-16T09:28:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephane\_Renou](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/stephane_renou/32/28309_2.png) [@Stephane\_Renou](https://community.sonarsource.com/u/Stephane_Renou)\
**Post date:** [March 16, 2026, 9:28am UTC](https://community.sonarsource.com/t/false-positive-for-python-s6546/179644/1 "2026-03-16T09:28:20Z")

</div>

Make sure to read this post before raising a thread here:

> [@How to Report a False-positive / False-negative](https://community.sonarsource.com/t/how-to-report-a-false-positive-false-negative/37022):
>
> Hey SonarSource Community! [False-positives happen](https://blog.sonarsource.com/false-positives-our-enemies-but-maybe-your-friends), as do false-negatives, and we’re eager to fix them. We are thrilled when our users report problems, so we can make our products better. What is a false-positive (FP)? A false-positive is when an issue is raised unexpectedly on code that should not trigger an issue, or where the suggested action doesn’t make any sense for the code. What is a false-negative (FN)? A false-negative is when an issue should be raised on a piece of code, but isn’t. …

Then tell us:

- What language is this for? Python
- Which rule? **[python:S6546](https://sonarcloud.io/organizations/visionairy/rules?open=python%3AS6546&rule_key=python%3AS6546)**
- Why do you believe it’s a false-positive/false-negative? Depending on how I write my code the rule triggers or not
- Are you using
  - SonarQube Cloud? yes
  - SonarQube Server / Community Build - which version?
  - SonarQube for IDE - which IDE/version?
    - in connected mode with SonarQube Server / Community Build or SonarQube Cloud?

- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

My fastapi code looks more or less like this:

```auto
def getresult(
    my_env: str,
    database: Annotated\[Database, Depends(current_database)\],
    regular_class: Annotated\[Dict\[str, ClassA | ClassB\], Depends(a_or_b)\],
    new_class: Annotated\[
        ClassC | ClassD, Depends(c_or_d)
    \],
):
my_code here

```

I am getting the sur S6546 to trigger on line ClassC | ClassD but not on ClassA | ClassB  
I think it should not trigger on any of those lines as the code uses the “or” operator and not the union operator.  
It seems that the fact that the code is spreaded on multiple lines creates the issue as I am getting this reported only when the code appears on 3 lines as showed here.

---

<div class="post-metadata">

**Author:** ![sebastian.zumbrunn](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sebastian.zumbrunn/32/64172_2.png) [@sebastian.zumbrunn](https://community.sonarsource.com/u/sebastian.zumbrunn)\
**Post date:** [March 23, 2026, 10:54am UTC](https://community.sonarsource.com/t/false-positive-for-python-s6546/179644/5 "2026-03-23T10:54:47Z")

</div>

Hi @Stephane_Renou,

Thanks for reaching out. I was able to reproduce the issue based on your snippet. This is indeed a false positive that occurs when a the new syntax is directly used in an `Annotated` type hint.

I’ve created a ticket in our internal bug tracker to track this.

Cheers,  
Sebastian
