Skip to content

Standard libraries don't support pathlib.Path objects #4455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aaltat opened this issue Sep 7, 2022 · 5 comments
Closed

Standard libraries don't support pathlib.Path objects #4455

aaltat opened this issue Sep 7, 2022 · 5 comments

Comments

@aaltat
Copy link
Contributor

aaltat commented Sep 7, 2022

OperatingSystem library should support also Python Path objects. Currently OperatingSystem library keyword which uses path or file path as argument, expect the argument to be as a string. Would it be possible to enhance library keyword to support also Python Path as arguments.

This could be useful when library keywords returns a path object and that object is example used in Get File. Currently users are required to do:

${path}    Library Keyword Return Path Object
${path}    Convert To String    ${path}
${data}    Get File    ${path}

But it could be handy to just do

${path}    Library Keyword Return Path Object
${data}    Get File    ${path}
@aaltat aaltat changed the title OperatingSystem library should support also Python Path objects OperatingSystem library could support also Python Path objects Sep 7, 2022
@pekkaklarck
Copy link
Member

All our libraries (and APIs) certainly should accept Path objects as paths. Which keywords have you had problems with?

A related question is that should keywords also return Path objects. For backwards compatibility reasons that's probably not a good idea in general, but if a keyword gets Path as an argument it could also return one.

@pekkaklarck pekkaklarck added this to the v5.1 milestone Sep 8, 2022
@pekkaklarck pekkaklarck changed the title OperatingSystem library could support also Python Path objects OperatingSystem library doesn't support pathlib.Path objects Sep 16, 2022
@pekkaklarck
Copy link
Member

OperatingSystem now supports pathlib.Path. Need to check are there other libs, especially XML and Process, that need this support as well.

@pekkaklarck
Copy link
Member

Somewhat related, we probably should add type conversion support for pathlib.Path.

pekkaklarck added a commit that referenced this issue Sep 16, 2022
Parsing alraedy worked with pathlib.Path but saving didn't.
@pekkaklarck pekkaklarck changed the title OperatingSystem library doesn't support pathlib.Path objects Standard libraries don't support pathlib.Path objects Sep 16, 2022
@pekkaklarck
Copy link
Member

Added pathlib.Path support to Process and XML. With the former it was possible to give stdout and stderr as pathlib.Path but not stdin or cwd. WIth the later parsing worked but saving didn't. Still need to check do other libs use paths.

pekkaklarck added a commit that referenced this issue Sep 16, 2022
Also some test data cleanup.
@pekkaklarck
Copy link
Member

Also Screenshot used paths and that's now fixed as well. That ought to be all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants