You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type hint for Plotly Express text_auto should accept str #5721
I am seeing a false-positive type-checking error in Pylance/Pyright when I use a documented numeric format string with text_auto in Plotly Express.
This report specifically concerns plotly.express.bar (the px.bar function exposed by import plotly.express as px), whose text_auto parameter is inferred as bool by Pylance/Pyright.
The runtime behavior is correct, and the documentation states that text_auto accepts either a boolean or a string. A string such as ".2f" is interpreted as a numeric texttemplate formatting directive.
Argument of type "Literal['.1f']" cannot be assigned to parameter "text_auto" of type "bool" in function "bar"
Expected behavior
Static type checking should accept both bool and str for text_auto, matching the documented and runtime API.
Notes
The current function signature uses an unannotated default:
text_auto=False
Pylance/Pyright therefore infers the parameter as bool from its default value.
Could the Plotly Express functions that expose text_auto be annotated as accepting both supported values? For compatibility with older Python versions, an annotation such as the following would address this:
Thanks for the report! As you mentioned, this error is from the inference that Pylance is doing. There's a long standing request to add type hints to plotly.py and we're interested in it, but it will take some dedicated time to get it done. One of our team members is interested in picking away at this, so I'll assign it to him and we'll see how far we can get. I'm going to close this issue as a duplicate of the original issue, #1103.
Activity
camdecoster commentedon Sep 9, 2026
Thanks for the report! As you mentioned, this error is from the inference that Pylance is doing. There's a long standing request to add type hints to plotly.py and we're interested in it, but it will take some dedicated time to get it done. One of our team members is interested in picking away at this, so I'll assign it to him and we'll see how far we can get. I'm going to close this issue as a duplicate of the original issue, #1103.