Is this nesting needed? This could be just a method of the class, without a need to receive any parameters (except self).

I'm also not sure why half the documentation is in a comment above, and half is in the docstring. Seems like the comments above are actually meant for line 872.