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

support for str instead of Path #365

Closed
veenstrajelmer opened this issue Oct 10, 2022 · 1 comment · Fixed by #469
Closed

support for str instead of Path #365

veenstrajelmer opened this issue Oct 10, 2022 · 1 comment · Fixed by #469
Assignees
Labels
type: enhancement Improvements to existing functionality

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Oct 10, 2022

Is your feature request related to a problem? Please describe.
Currently, it is necessary to import Path whenever using hydrolib functions: from pathlib import Path

Describe the solution you'd like
This is acceptable, but I can imagine it would be fairly easy to add support for plain strings also, by converting all strings to Path(str) in hydrolib. This saves a bit of a hassle. At least, if chosen not to add support, I would suggest to raise a more explanatory error than this:
AttributeError: 'str' object has no attribute 'is_absolute'

Instead, explicitly informing the user to wrap Path() around the provided string.

@arthurvd arthurvd added the type: enhancement Improvements to existing functionality label Mar 10, 2023
@MRVermeulenDeltares MRVermeulenDeltares self-assigned this Mar 15, 2023
@MRVermeulenDeltares
Copy link
Contributor

in the FileModel class, the filepath variable can have a check on the input for path.
in the FileModel class, the save method can have a check on the input for path.
in the FileModel class, the constructor can have a check on the input for path.
Classes inheriting from the FileModel will have the path input resolved via the parent class.
e.g. the DIMR class inherits from the ParsableFileModel which in turn inherits from FileModel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants