如何记录嵌套和不确定类型?

时间:2019-01-21 15:47:27

标签: python python-3.x code-documentation

我正在尝试记录查询数据库的函数的返回类型。我的尝试是这样的:

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
    services.AddSwaggerGen(c =>
    {
        c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
    });

    ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseSwagger();

    app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
    });

    ...
}

但是我真的不确定“ rtype”。 这是此类对象的示例:

"""
Execute the query, append a report to the file (start & end time, duration, n rows and result file) and copy results
next to the original file with the same file name but the extension being csv.

:param file_path: file containing a single SQL query
:type file_path: str
:return: data queried from the database
:rtype: {'headers': list<str>, 'rows': list<tuple<any>>}
"""

因此,使用键“ headers”托管str的列表和使用键“ rows”托管不确定类型的元组的列表是dict。 我想这里有两个问题:

  1. 如何记录嵌套类型? { "headers": ["id", "name"], "rows": [ (1, "Adrien"), (2, "Simon") ] } 可以吗?
  2. 如何记录未确定的类型? GenericType<SubType>可以吗?

我正在寻找是否存在约定。

0 个答案:

没有答案