ofek / userpath

Cross-platform tool for adding locations to the user PATH, no elevated privileges required!
MIT License
151 stars 20 forks source link

append should ideally return a filepath (or tuple of filepaths) not a bool! #59

Open bernd-wechner opened 2 weeks ago

bernd-wechner commented 2 weeks ago

Just browsing the cod because pipx depends on it and its ensurepath options make unspecified changes to the file system. Drilling down into those, I find it relies blindly on userpath.append() function.

That function returns a boolean for success or failure. IMHO and this is merely my view on the matter of course, it should ideally return either None (for failed) or a string, or a tuple of strings if it succeeded, the string or tuple of stings containing the file paths of all files modified in the process.

This should be backward compatible, evaluating None as False and a string or tuple thereof, as True in any Python boolean context anyhow, breaking only any apps that (strangely) tested explicitly against False or True values.

In any case, IMHO a package like this making changes to the system files should inform upstream of what files were changed for transparency and integrity.

I say a filepath or tuple thereof because if it's just one a string suffices, if you modify all shells for example then a list is needed. For consistency, perhaps always a tuple with 1-tuples returned when only one shell is updated.