Giter Club home page Giter Club logo

Comments (8)

gaborbernat avatar gaborbernat commented on June 17, 2024

this would be a pain to support for a Path Type

We could introduce the contract that path variants always return the first of the multipath. If users want multipath they would need to do: user_data_dir().split(os.pathsep), at which point they can cast the elements into Path if they'd wish to 🤔

from platformdirs.

papr avatar papr commented on June 17, 2024

We could introduce the contract that path variants always return the first of the multipath.

Alternatively, site_data_path could return a list of pathlib.Path objects if multipath=True was passed. Ideally, site_data_dir would return a list of strings in that case, too (as suggested by @RonnyPfannschmidt). But this wouldn't be backwards compatible, correct?

From what I can see, site_data_dir is the only affected API here, correct?

from platformdirs.

gaborbernat avatar gaborbernat commented on June 17, 2024

It also would mutate the type returned based on a boolean flag which I don't like at all 😬

from platformdirs.

papr avatar papr commented on June 17, 2024

We could introduce the contract that path variants always return the first of the multipath.

In other words, the multipath flag would have no effect on site_data_path. It will simply always return the first path, which is the default for site_data_dir if multipath is not set.

How come that there is a binary flag for this anyway? Wouldn't it make more sense to have two new api calls: site_data_dir_list and site_data_path_list?

from platformdirs.

gaborbernat avatar gaborbernat commented on June 17, 2024

Because for dirs the return type does not change 😬 because we don't return the paths as a list are but joined by os.pathsep. obviously we can't do that for pathlib.

from platformdirs.

papr avatar papr commented on June 17, 2024

Because for dirs the return type does not change

That is of course correct, but their output changes semantically, i.e. as a user I have to handle multipath output differently than singlepath output. It looks to me like all the arguments of a boolean-flag trap apply here as well. Nonetheless, #27 follows your suggestion to only return the first item in case site_data_dir is called with multipath=True.

from platformdirs.

gaborbernat avatar gaborbernat commented on June 17, 2024

That is of course correct, but their output changes semantically, i.e. as a user I have to handle multipath output differently than singlepath output.

Not really, UNIX site config values always return paths joined by os.pathsep... In simple case just happens to not matter, because joining an array of length 1 is always the same as the array element.

from platformdirs.

gaborbernat avatar gaborbernat commented on June 17, 2024

We solved this for now by picking first for paths. str endpoints still work.

from platformdirs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.