Skip to content

Typing – Traversable vs MultiplexedPath return value of files() #286

@frenzymadness

Description

@frenzymadness

Related to: python/cpython#106614 and #263

I see two possible workarounds for the mentioned issue:

str((files("jupyterlab_server.test_data") / "dummy").parent)

or

str(files("jupyterlab_server.test_data")._paths[0])

but both have issues with typing because the signature of files function is:

def files(anchor: Optional[Anchor] = None) -> Traversable:

In my specific case, files always returns MultiplexedPath so both workarounds are fine but mypy complains about it because Traversable neither has _paths not parent attributes.

When I tried to change the return value in the annotation from Traversable to MultiplexedPath mypy did not complain about it so it seems that the function cannot return anything else than MultiplexedPath. Is that correct? Would it make sense to make the type annotation more specific?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions