Hello python gurus I'm hoping to get a little guidance on best practise.
So I'm developing a fairly extensive set of geoprocessing tools in a toolbox (atbx) using python. For my own sanity I have decided to improve the readability of my code by employing hinting in my function parameters. Here is a short article that covers the topic. I have looked at a few of the system script tools and ESRI developers don't seem to employ hinting so there are no examples to work from, hence me coming here.
This is not something I have done before in python and coming from a VB background seems to me like a very useful improvement to my code. I've always preferred strongly typed languages when coding.
So I'm happy with setting basic built-in types for example in the past I might have done:
def mytest(age, name):
text = "Hello " + name + ", you are" + str(age)
return text
But with hinting used I now write my function as:
def mytest(age: int, name: str) -> str:
text = "Hello " + name + ", you are" + str(age)
return text
So my question is how do I hint for arcpy objects, say for a layer, spatial reference or polyline? Imagine I had some function like this:
def dostuff(mylayer, sr, arr):
# Nonsene example showing the variety of arcpy objects I might pass into a function
arcpy.AddField_management(mylayer, "SiteID", "LONG")
myPolyline = arcpy.Polyline(arr, sr, False, True)
return myPolyline
What would be the correct hinting syntax to be used for my dostuff() function which is passing in arcpy objects or even a class object I might have created?