Refactor: use dict comprehension in _get_endpoint_prefix_to_name_mappings

Open Beginner friendly
#10,570 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
90/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Open awscli/customizations/configure/addmodel.py and inspect _get_endpoint_prefix_to_name_mappings around lines 21-28. Compare the current manual loop with the proposed comprehension and verify that the endpoint-prefix-to-service-name mapping remains unchanged. Done means the function uses the requested comprehension without changing behavior.

Written by the indexing model from the issue text.

Description

needs-triage

Summary

`_get_endpoint_prefix_to_name_mappings` in `awscli/customizations/configure/addmodel.py` (lines ~21-28) builds a dict manually with an empty-dict-then-loop-assignment pattern, where the loop body does nothing but a single key/value assignment.

Proposed change

Replace with a dict comprehension:
```python
return {
session.get_service_model(service_name).endpoint_prefix: service_name
for service_name in session.get_available_services()
}
```
Pure refactor, no behavior change.

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

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.