-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix: Display deprecated warnings for mapbox traces #4900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@LiamConnors When you have a chance, could you sanity check whether the warnings are working as expected for you on this branch? I.e. that we see a warning when using the deprecated traces, but no warnings otherwise.
It's working as expected. Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilykl Good improvement. And I can approve this PR.
As follow ups to this PR:
Could you possibly
- double check that
stacklevel=2is the best option we could use? - should we use similar
stacklevelandcategoryoptions for other warnings in plotly.py?
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe stacklevel=2 is the correct option in this case -- it causes the warning to appear to be emitted at the place in the user's code where they have called the deprecated function, for example:
Making a go.Choroplethmapbox figure...
/Users/ekl/code/plotly.py/my_script.py:32: DeprecationWarning:
*choroplethmapbox* is deprecated! Use *choroplethmap* instead. Learn more at: https://plotly.com/python/mapbox-to-maplibre/
(Also, for DeprecationWarning specifically, using any other stacklevel for these deprecations causes the warning to not appear at all.)
It's just coincidence that stacklevel=2 is the correct option in this case for both the go and px deprecations... the correct stacklevel will differ in every case depending on exactly where the warning is being emitted.
I don't think it's worth the effort to go through the codebase and clean up existing warnings, but I do think it makes sense to use stacklevel and category consistently going forward. It seems at least some of the warnings already in place in Plotly.py are using them correctly.
Uh oh!
There was an error while loading. Please reload this page.
Closes #4730.
Adds deprecation warnings which are printed to the console when using one of the following objects / functions:
graph objects:
go.Choroplethmapboxgo.Densitymapboxgo.Scattermapboxexpress:
px.choropleth_mapboxpx.density_mapboxpx.scatter_mapboxpx.line_mapboxSince the graph objects files are generated by codegen, this PR also modifies the codegen process to automatically add the deprecation warnings to the generated files.