Windows 10, SonarLint v3.22.0, Python, not connected
ellipsis = ""
"message": "Rename this variable; it shadows a builtin.",
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)
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:
As a result, it shouldn’t be shadowed.
Let me know if you have any other questions.
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.
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
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
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.
I implemented a temporary fix to the FP. A more definite solution will be implemented as part of this ticket.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.