Currently the only type that has an interface in the mp module is `ArcGISProject`. This causes tons of headaches when working with any other mapping classes as Pylance has no idea what any of the types in the module are. This has already been done for a lot of da module objects (*Cursor, Editor, etc.), but for some reason the mp module is still reliant on the developer reading the documentation online for each type instead of allowing for Pylance to provide documentation inline.
Proposed fix:
`_mp.py` ->
...
__all__ = ["ArcGISProject", "Bookmark", "BookmarkMapSeries", "Camera",
"ElevationSurface", "ElevationSource", "GraphicElement",
"GroupElement", "LabelClass", "Layer", "LayerFile", "LayerTime", "Layout",
"LegendElement", "LegendItem", "Map", "MapFrame", "MapSeries", "MapSurroundElement",
"MapTime", "MapView", "PictureElement", "Report", "ReportLayoutSection",
"ReportSection", "StyleItem", "Table", "TableFrameElement", "TextElement"]
...
`mp.py` ->
...
from arcpy._mp import *
...
Alternatively the method used by the da module could be used by mp as well:
...
__all__ = [item for item in dir(da) if not item.startswith('_')]
locals().update(da.__dict__)
del da
...
With da being replaced by mp of course.
Final option is to create a `stubs/mp.pyi` that explicitly types all classes and methods for the mp module. See da.pyi in the arcpy module root for an example. This would probably be the best option as it wouldn't require modifying anything in the mp module itself (other than making sure all interfaced classes are in the mp.py namespace using some import method)
Thank you for your feedback. We hope to incorporate type hints into many more of our classes for the 3.5 release.
Jeff - arcpy.mp and Layout teams
Hi @HaydenWelch! This Idea was implemented with the ArcGIS Pro 3.5 release. To see what else is new in the world of arcpy.mp, checkout the What's new in ArcGIS Pro 3.5 documentation and the Your Ideas in ArcGIS Pro 3.5 blog on Esri Community.
Thank you guys so much for finally moving on the typing updates, you have no idea how much of a headache you've saved me. Been using a modified development version of arcpy for a while now and seems like I can finally ditch that and get back on the standard environment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.