Skip to content
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

FileConfigEntry and DirectoryConfigEntry without slash check #95

Closed
wants to merge 0 commits into from

Conversation

claudius-kienle
Copy link

The FileConfigEntry and DirectoryConfigEntry both check if the path has a trailing os.sep or not. However, on windows, pathlib, as well as git bash, can work with both trailing and forward slashes. Consequently, this check would throw an error with following file path, even if it has the correct format. Additionally, trailing slashes are not required to form a valid directory path.

E.g. C:/Users/my.user/Documents/ would be rejected as path on windows.

Removing those os.sep checks fixes that

@markusressel
Copy link
Owner

markusressel commented Jul 10, 2024

Hey @claudius-kienle !
Sorry but it seems I missed your PR 😲 😞

Hmm, thinking about this, i think the initial reason I did it this way was to somehow differentiate between file paths and directory paths, but I can't remember why. Reading your explanation it doesn't make a lot of sense to me now 🤔
If directories do not require a trailing slash it would make sense to remove the check. However, before I go ahead and merge your PR I want to make sure there was no other valid reason to do this.

@markusressel markusressel self-assigned this Jul 10, 2024
@markusressel markusressel added the bug Something isn't working label Jul 10, 2024
@markusressel
Copy link
Owner

markusressel commented Jul 13, 2024

OK so I had a look.

First of all the test are failing, which is expected, but for some reason they are not configured correctly to run on a PR.
I have hopefully fixed that now.

Secondly: While omitting the trailing slash for a directory path is valid, a file path with a trailing slash should not be parsed as a correct file path. At least thats not valid on linux, so I expect it also isn't on other systems. I have therefore reverted this change.

Thirdly: I thought that os.sep would be a forward slash on windows, and a backward slash on linux. It seems like this is not the case, giving you the error you mentioned. Since - as you mentioned - pathlib can work with both, removing the check there seems reasonable.

@markusressel
Copy link
Owner

@claudius-kienle sorry, I think I messed up something in git, not sure how that happened 🤔
I was trying to force-push to your branch but seemingly with the wrong state. Since the PR closed automatically, I have no permissions to fix that now 🙄

I have included your commits through a local merge now. Thx for the contribution!

@claudius-kienle
Copy link
Author

@markusressel . No worries. Thanks for integrating my changes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants