Bug Fix: ABC News#490
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds version history to the docstring and implements logic to handle feeds with fewer than five headlines. Feedback includes removing the manual version history, renaming the file to match the directory name per naming conventions, and using list slicing with extend for a more idiomatic implementation.
|
|
||
| v1.0 | ||
| First release | ||
|
|
||
| v1.1 | ||
| Added handling for when less than 5 stories in the feed |
There was a problem hiding this comment.
Remove the version history from the docstring. This information is typically managed via source control tags (e.g., Git) rather than manually maintained within the file. Additionally, the Starlark file should have the same base name as its containing directory (e.g., 'abcnews.star' instead of 'abc_news.star').
References
- The Starlark file containing the main() function should have the same base name as its containing directory.
| # just in case less than 5 stories in the feed | ||
| feed_length = min(len(title), 5) | ||
|
|
||
| for i in range(0, feed_length, 1): | ||
| desc = title[i] | ||
| description.append(desc) |
There was a problem hiding this comment.
The loop and manual length calculation can be simplified using list.extend() with a slice. Starlark supports slicing, which is more idiomatic and automatically handles cases where the list contains fewer than the requested number of elements.
| # just in case less than 5 stories in the feed | |
| feed_length = min(len(title), 5) | |
| for i in range(0, feed_length, 1): | |
| desc = title[i] | |
| description.append(desc) | |
| description.extend(title[:5]) |
Added handling for when less than 5 stories in the feed