Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UPath(path).parent does not work as expected for memory URIs with authority component #161

Closed
@kadykov

Description

@kadykov

.parent() method of the paths pointing to the files in the root directory returns the filename with added slash, instead of root symbol.
This issue blocks PR in intake

Code to reproduce:

from upath import UPath

def get_dir(path):
    return str(UPath(path).parent)

print(f"{get_dir('memory://cat.yml') = }")  # 'memory://cat.yml/'
print(f"{get_dir('memory://dir/cat.yml') = }")  # 'memory://dir/'
print(f"{get_dir('file://cat.yml') = }")  # 'file://cat.yml/'
print(f"{get_dir('file://dir/cat.yml') = }")  # 'file://dir/'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions