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

Open Beginner friendly
#10,566 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Start by reviewing PosixHelpRenderer._exists_on_path and the surrounding imports in awscli/help.py, around lines 162-170. Done means the manual PATH walk is replaced as proposed without changing the method's behavior.

Written by the indexing model from the issue text.

Description

needs-triage

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.

Dominant language
Python
Stars
17.3k
Forks
4.7k
Avg merge
1d 23h
Merged PRs (30d)
25

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/aws-cli

All issues in aws/aws-cli

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.