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

Issue #184 and #239 Added types and defaults to function help text.

Open MichaelCG8 opened this issue 5 years ago • 9 comments

MichaelCG8 avatar Apr 26 '20 18:04 MichaelCG8

I've just ran pylint and it looks like I got some of the indentation wrong, so I'll fix that tomorrow. Also running pylint with a py2 interpreter doesn't like some of the py3 only tests, so I'll add pylint disable comments to those.

MichaelCG8 avatar Apr 26 '20 21:04 MichaelCG8

I'd handled the tests using type hints by putting them in a string and conditionally calling exec on them if the version was >3.5. I've now changed this so that they are in a conditionally imported module, following the approach taken with fire/test_components_py3.py Linting issues are addressed, so this is now ready for your feedback. Thanks! Michael

MichaelCG8 avatar Apr 27 '20 11:04 MichaelCG8

Looks good!

We'll make some small changes as part of merging, but no need to take additional action on your part. 👍

One point for discussion: You truncate types and defaults with ... <clipped> I think it's cleaner without the text <clipped>. Wdyt? I also think we should be visually consistent between how we truncate long string descriptions and summaries (see custom_descriptions.GetStringTypeSummary).

dbieber avatar May 01 '20 19:05 dbieber

Good suggestion. I started with <clipped> then changed it to ... <clipped>, I didn't consider just the ellipsis alone, but I agree that that is better.

I see that custom_descriptions.GetStringTypeSummary uses formatting.EllipsisTruncate, I've applied that to the code and it tidies things up a lot.

MichaelCG8 avatar May 01 '20 20:05 MichaelCG8

Is there any update on when is this going to be merged?

rragundez avatar Jun 18 '20 10:06 rragundez

We ran into an error when merging initially. The long_type test fails internally: AssertionError: 'POSITIONAL ARGUMENTS\n LONG_OBJ\n Type: typing.Tuple[typing.Tuple[typing.Tuple[typing.Tuple[typing.Tupl...' not found in 'NAME\n long_type\n\nSYNOPSIS\n long_type LONG_OBJ\n\nPOSITIONAL ARGUMENTS\n LONG_OBJ\n Type: Tuple\n\nNOTES\n You can also use flags syntax for POSITIONAL ARGUMENTS'

typing.Tuple.__qualname__ is defined as "Tuple" internally, but is an AttributeError externally. Going to disable the test and merge so we can make progress.

Thanks for your patience.

dbieber avatar Jul 10 '20 17:07 dbieber

Hi David, thanks for looking at this! Interesting about the failing test, I tested on py3.7.7 and py2.7.18 without seeing the failure, was this seen on another python version? Or are you running these tests with some additional stuff merged in since I forked?

MichaelCG8 avatar Jul 11 '20 08:07 MichaelCG8

It's Python 3.6.7 that it's failing on, but I think we may be using a nonstandard typing library. It passes on Travis, but fails on the Google testing infrastructure. When I run import typing; typing.Tuple.__qualname__ in Python 3.7.7, I get an AttributeError (which would make the test pass.) When I run import typing; typing.Tuple.__qualname__ in the Google-internal Python 3.6.7, it gives "Tuple" (which causes the test failure.)

Or are you running these tests with some additional stuff merged in since I forked?

I made a few small changes but nothing substantial. Hopefully early in the week I'll merge the PR with those small changes.

dbieber avatar Jul 11 '20 18:07 dbieber

Merged with 79d85df2706b2dab5dd5075f2a76953743ee9bf3

dbieber avatar Jul 14 '20 17:07 dbieber

As noted in the previous comment https://github.com/google/python-fire/pull/251#issuecomment-658325840 this was already merged in Jul 2020. Closing. The GitHub status of the PR will unfortunately not reflect that this was an accepted PR, (though the commit is attributed correct) -- sorry about that.

dbieber avatar Dec 09 '22 21:12 dbieber