python-fire icon indicating copy to clipboard operation
python-fire copied to clipboard

bug fix for help from typing package, add test for optional and union

Open Jemeljanov opened this issue 1 year ago • 4 comments

Closes #508

Fixed bug where objects from typing instance were not displayed correctly mentioned in #508 and also Union types.

Added tests for typing.Union and typing.Optional

Other notes

Removed comment as the edge case mentioned is handled by new code.

Used arg_type = repr(arg_type).replace('typing.', '') to output a shorter message for user

Jemeljanov avatar May 21 '24 18:05 Jemeljanov

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar May 21 '24 18:05 google-cla[bot]

Thanks for putting this together! At a quick glance, this LGTM. One comment inline above.

dbieber avatar May 22 '24 21:05 dbieber

@dbieber it was a little bit different behaviour now it will be Optional[Union[int, str]], the Optional is because the default is None.

Now it is more in compliance with the typing in python code and a more robust version than with regular expression.

Additional check is to prevent the Optional repetition (one added from python-fire the other from typing package).

Jemeljanov avatar May 22 '24 22:05 Jemeljanov

I only just enabled CI for pull requests so this didn't surface earlier -- it looks like there are some test failures.

dbieber avatar Sep 21 '24 20:09 dbieber