I am attempting to remove all Annotation Subclass layers from a list that is generated from a Map inside of ArcPro.
From what I can tell the subclasses must be a "Layer" inside of Pro.
I cannot find a method to conclusively distinguish which layers are annotation subclasses.
l <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>list of Layer Objects<SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> l<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> x<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
desc <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>desc<SPAN class="punctuation token">.</SPAN>featureClass<SPAN class="punctuation token">.</SPAN>featuretype<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>f<SPAN class="string token">"{x} cannot be described"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>This will yield "Annotation" for both the Annotation layer, and its subclasses.
desc<SPAN class="punctuation token">.</SPAN>name<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
This will yield the Name of the Annotation layer for all subclasses
<SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> l<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> x
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
generates an error **NameError: The attribute 'longName' is not supported on this instance of Layer** as soon as it hits the Annotation subclass