-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply type casting & remove empty kwarg for Command #108
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #108 +/- ##
==========================================
+ Coverage 78.78% 79.05% +0.27%
==========================================
Files 14 14
Lines 1499 1509 +10
Branches 269 272 +3
==========================================
+ Hits 1181 1193 +12
+ Misses 230 229 -1
+ Partials 88 87 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* Applied type casting & remove empty kwarg for Command ([#108](#108)). A new method, `get_argument_type`, has been added to the `Command` class in the `cli.py` file to determine the type of a given argument name based on the function's signature. The `_route` method has been updated to remove any empty keyword arguments from the `kwargs` dictionary, and apply type casting based on the argument type using the `get_argument_type` method. This ensures that the `kwargs` passed into `App.command` are correctly typed and eliminates any empty keyword arguments, which were previously passed as empty strings. In the test file for the command-line interface, the `foo` command's keyword arguments have been updated to include `age` (int), `salary` (float), `is_customer` (bool), and `address` (str) types, with the `name` argument remaining and a default value for `address`. The `test_commands` and `test_injects_prompts` functions have been updated accordingly. These changes aim to improve the input validation and type safety of the `App.command` method.
* Applied type casting & remove empty kwarg for Command ([#108](#108)). A new method, `get_argument_type`, has been added to the `Command` class in the `cli.py` file to determine the type of a given argument name based on the function's signature. The `_route` method has been updated to remove any empty keyword arguments from the `kwargs` dictionary, and apply type casting based on the argument type using the `get_argument_type` method. This ensures that the `kwargs` passed into `App.command` are correctly typed and eliminates any empty keyword arguments, which were previously passed as empty strings. In the test file for the command-line interface, the `foo` command's keyword arguments have been updated to include `age` (int), `salary` (float), `is_customer` (bool), and `address` (str) types, with the `name` argument remaining and a default value for `address`. The `test_commands` and `test_injects_prompts` functions have been updated accordingly. These changes aim to improve the input validation and type safety of the `App.command` method.
Currently, all kwargs are passed into
App.command
asstr
. Empty kwarg is passed as empty string.In this PR, we remove any empty kwarg, and apply casting based on the kwarg annotation for primitive types