Skip to content

Refactor: use shutil.which instead of manual PATH walk in PosixHelpRenderer #10566

Description

@Adityaj0

Summary

`PosixHelpRenderer._exists_on_path` in `awscli/help.py` (lines ~162-170) manually reimplements PATH lookup by joining each PATH entry with `os.path.join`/`os.path.exists` inside a list comprehension, then calls `any()` on the resulting list.

Proposed change

Use the stdlib `shutil.which` (available since Python 3.3): `return shutil.which(name) is not None`. Removes the manual PATH-walking logic and avoids building a throwaway list. Pure refactor, no behavior change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions