Looking to clean up some code by using a namedtuple to hold multiple variables for passing through a number of functions. Below is a simplified example (I actually have a few more additional arguments).
Before:
def my_function(session_cass, session_solr, session_mysql, some_var, another):
"""Blah blah.
Args:
session_cass (Session): Cassandra session to execute queries with.
session_solr (SolrConnection): Solr connection to execute requests with.
session_mysql (connection): MySQL connection to execute queries with.
some_var (str): Yada yada.
another (int): Yada yada.
"""
After:
def my_function(sessions, some_var, another):
"""Blah blah.
Args:
sessions (namedtuple): Holds all the database sessions.
some_var (str): Yada yada.
another (int): Yada yada.
"""
For docstrings, I've been following the Google style guide, with the addition of types (inspired by this post), which I really like because it makes it a lot easier to keep track of what types are coming in.
My question is, how would you go about documenting a namedtuple in this scenario? Obviously as it's currently set up, you have no information about the types within the namedtuple. Is there an accepted way to extend the docstring here, or document the namedtuple where it's defined (not shown)?
I know you could document a class in this manor, but I'm trying to stay away from using a class as I don't really have any purpose for it other than to hold the variables.