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
Adds deprecation warnings which are printed to the console when using one of the following objects / functions:
graph objects:
go.Choroplethmapbox
go.Densitymapbox
go.Scattermapbox
express:
px.choropleth_mapbox
px.density_mapbox
px.scatter_mapbox
px.line_mapbox
Since 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.
emilykl
changed the title
Fix: Display deprecated warnings for mapbox traces and skip their template validationFix: Display deprecated warnings for mapbox tracesNov 25, 2024
@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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.