Skip to content

[bug]The type hint of array_of_inline_tables seems to be wrong #3523

@monchin

Description

@monchin

Describe the bug

Currently the definition of array_of_inline_tables is

def make_inline_table(data: Mapping) -> dict:
    """Create an inline table from the given data."""
    table = cast(dict, tomlkit.inline_table())
    table.update(data)
    return table


def make_array(data: list, multiline: bool = False) -> list:
    if not data:
        return []
    array = cast(list, tomlkit.array().multiline(multiline))
    array.extend(data)
    return array


def array_of_inline_tables(value: list[Mapping], multiline: bool = True) -> list[str]:
    return make_array([make_inline_table(item) for item in value], multiline)

From the source code, it seems that the return value of array_of_inline_tables should be list[dict] as the data in make_array should be list[dict]

To reproduce

No reproduce

Expected Behavior

mypy or pyright should infer to list[dict] as the return value type

Environment Information

PDM version:
2.24.2

{
  "implementation_name": "cpython",
  "implementation_version": "3.10.11",        
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.19045",
  "python_full_version": "3.10.11",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "win32"
}

Verbose Command Output

No response

Additional Context

No response

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions