Skip to content

bug: bindir argument for get_pestpp(.run_main) fails if type is Path #2558 #612

@martinvonk

Description

@martinvonk

Describe the bug
The pyemu.utils.get_pestpp.run_main function downloads PEST++. A bindir argument has to be provided, of type str or Path according to the docstring. There is call to the .startswith method on line 379 However, a Path object does not have a .startswith method.

To Reproduce
Steps to reproduce the behavior:

from pathlib import Path
import pyemu

bindir = Path("bin")
bindir.mkdir(parents=True, exist_ok=True)

pyemu.utils.get_pestpp.run_main(bindir)

raises

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

File ~/repos/pyemu/pyemu/utils/get_pestpp.py:379, in run_main(bindir, owner, repo, release_id, ostag, subset, downloads_dir, force, quiet, _is_cli)
    376 exe_suffix, lib_suffix = get_suffixes(ostag)
    378 # select bindir if path not provided
--> [379] if bindir.startswith(":"):
    380     bindir = select_bindir(
    381         bindir, previous=prev_bindir, quiet=quiet, is_cli=_is_cli
    382     )
    383 elif not isinstance(bindir, (str, Path)):

AttributeError: 'PosixPath' object has no attribute 'startswith'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions