False-positive python:S5806 for ellipsis

Windows 10, SonarLint v3.22.0, Python, not connected


def fun():
    ellipsis = ""


	"resource": "bug.py",
	"owner": "sonarlint",
	"code": "python:S5806",
	"severity": 4,
	"message": "Rename this variable; it shadows a builtin.",
	"source": "sonarlint",
	"startLineNumber": 2,
	"startColumn": 5,
	"endLineNumber": 2,
	"endColumn": 13

However, I am not aware of ellipsis being a builtin. The proper name is Ellipsis (Built-in Constants — Python 3.12.0 documentation, 4. Built-in Constants — Python 2.7.18 documentation)

Hi @bers,

Thank you very much for bringing this to our attention. It turns out that ellipsis is actually the built-in type for Ellipsis. Indeed, you may find that:

<class 'ellipsis'>

As a result, it shouldn’t be shadowed.

Let me know if you have any other questions.


Hi @jeremi.dodinh,
thanks for your answer, which is interesting but appears incorrect to me. Yes, the type of Ellipsis is shown as ellipsis, but that does not mean that ellipsis is a shadow-able built-in. Actually, ellipsis is not defined on a Python (3.12) prompt. In addition, the type of Ellipsis is accessible via types.EllipsisType, which it seems was introduced in Python 3.10, and which would not have been necessary to introduce if something as simple as ellipsis existed (right?). Compare https://github.com/python/cpython/issues/85976.

>>> ellipsis
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'ellipsis' is not defined. Did you mean: 'Ellipsis'?
>>> import types; types.EllipsisType
<class 'ellipsis'>

By the way, Sonar does not annotate Ellipsis as a built-in, and that is a false-negative. I think someone just made an honest mistake by adding ellipsis to the list of built-ins instead of Ellipsis. In line with this, ruff (A003) flags Ellipsis but not ellipsis.

Hi @bers,

Thanks for the clarification, and I’m sorry for the incorrect response. I will be looking into this today, and I have created a ticket for that purpose.

I will keep you in touch about progress.


Hello @bers,

I implemented a temporary fix to the FP. A more definite solution will be implemented as part of this ticket.


1 Like

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