classification
Title: pygettext doesn't extract docstrings for functions with type annotated params
Type: behavior Stage: patch review
Components: Demos and Tools Versions: Python 3.6, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Tobotimus
Priority: normal Keywords: patch

Created on 2017-12-05 10:36 by Tobotimus, last changed 2017-12-07 09:31 by Tobotimus.

Files
File name Uploaded Description Edit
test_typehinted_funcs.py Tobotimus, 2017-12-05 10:36 Input file for pygettext to demonstrate behaviour
pygettext_output.pot Tobotimus, 2017-12-05 10:37 Output file from pygettext for test_typehinted_funcs.py
test_returntypehinted_funcs.py Tobotimus, 2017-12-05 10:47 Demonstrating behaviour with return type annotations
Pull Requests
URL Status Linked Edit
PR 4745 open Tobotimus, 2017-12-07 09:31
Messages (3)
msg307652 - (view) Author: Toby Harradine (Tobotimus) * Date: 2017-12-05 10:36
### Expected Behaviour
When running pygettext with the -D CLI flag, all module, class, method and function docstrings should be extracted and outputted to the .pot file.

### Actual Behaviour
In the case of functions whose parameters have PEP 484 type annotations, their docstrings are not being extracted. I have attached two files, one .py file and its corresponding .pot file, as examples of this behaviour.
msg307654 - (view) Author: Toby Harradine (Tobotimus) * Date: 2017-12-05 10:47
Correction for above: the type annotation syntax is actually from PEP 3107, not PEP 484.

I should also point out that this behaviour is occurring for annotated return types of functions and methods as well.

This is occurring on both Windows and Linux.
msg307791 - (view) Author: Toby Harradine (Tobotimus) * Date: 2017-12-07 07:34
Another correction; I said that this is occurring for return type annotations; this is not true. This is only occurring for functions with annotated *arguments*.

The cause of this issue is in pygettext's TokenEater.__suiteseen method. This method eats tokens until it sees a colon operator, after which it assumes a function docstring may follow. In the case of a function with annotated arguments, obviously this is incorrect, as colons would appear before the final colon of the 'suite'.
History
Date User Action Args
2017-12-07 09:31:54Tobotimussetkeywords: + patch
stage: patch review
pull_requests: + pull_request4648
2017-12-07 07:34:51Tobotimussetmessages: + msg307791
2017-12-05 10:47:39Tobotimussetfiles: + test_returntypehinted_funcs.py

messages: + msg307654
2017-12-05 10:37:30Tobotimussetfiles: + pygettext_output.pot
2017-12-05 10:36:15Tobotimuscreate