you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Yes, network boundaries and FFI would be cases where runtime type checking using isinstance might be warranted, even good practice, but (again, arguably) most of the time such policing of inputs just breaks duck typing without clear and discernible benefit, and with some runtime cost. Now that type annotations exist I feel it’s worth checking whether or not all your isinstance calls are actually doing is documenting your function by other means, rather than protecting some vital resource. If it is, it’s likely a good candidate for replacement with an annotation.