fix: normalize GitHub language names to gtrending params#133
Open
fuleinist wants to merge 1 commit intohedyhli:mainfrom
Open
fix: normalize GitHub language names to gtrending params#133fuleinist wants to merge 1 commit intohedyhli:mainfrom
fuleinist wants to merge 1 commit intohedyhli:mainfrom
Conversation
When using -d (date_range), starcli calls gtrending.fetch_repos() which expects language params like 'c#' but GitHub uses 'csharp'. This caused a ValueError for languages whose GitHub identifier differs from gtrending's expected param (e.g. csharp, cpp). Add a GITHUB_TO_GTRENDING_LANG mapping for known mismatches and a _normalize_lang_for_gtrending() helper. Both gtrending.fetch_repos() calls in search_github_trending() now normalize the language first. Fixes hedyhli#111
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: csharp language fails with -d filter (ValueError)
Problem: Using
-l csharp -d todayraisesValueError: Invalid language argument: csharp, while-l csharp(without -d) works fine.Root cause: When
-d(date_range) is set, starcli callsgtrending.fetch_repos()which validates language against its internal param list. gtrending usesc#but GitHub usescsharp— different identifiers for the same language.Solution: Add a
GITHUB_TO_GTRENDING_LANGmapping for known mismatches (csharp → c#,cpp → c++) and a_normalize_lang_for_gtrending()helper. Bothgtrending.fetch_repos()calls insearch_github_trending()now normalize the language first.Files changed:
starcli/search.py(+17 lines)Testing:
starcli -l csharp -d todayshould no longer raise ValueErrorFixes #111