dropbox / pyannotate

Auto-generate PEP-484 annotations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type annotation does not with in Python 3.5

jabdoa2 opened this issue · comments

For some reason pyannotate with the workaround from #12 does not annotate my files:

PYTHONPATH=/usr/local/lib/python3.5/dist-packages/ pyannotate -w -v "mpf/core/data_manager.py"
Generating grammar tables from /usr/lib/python3.5/lib2to3/PatternGrammar.txt
Adding transformation: annotate_json
Refactoring mpf/core/data_manager.py
No changes in mpf/core/data_manager.py
No files need to be modified.

However, it definitely found some missing annotations in type_info.json:

    {   
        "func_name": "DataManager.__init__",
        "path": "mpf/core/data_manager.py",
        "type_comments": [
            "(mpf.tests.MpfTestCase.TestMachineController, str, int) -> None"
        ],
        "line": 18,
        "samples": 5
    },

And the code looks like this:

class DataManager(MpfController):

    """Handles key value data loading and saving for the machine."""

    def __init__(self, machine, name, min_wait_secs=1):
        [...]

Any idea what is going wrong here?

I was also bit by this, but got it to work on 3.5 by dumping the type info in the same dir where my source files are located, and invoking pyannotate from there as well. e.g.

$ pyannotate -w data_manager.py

That does not seem to help for me. Same output but no changes to the file.

Is there an existing type comment in the __init__ function?

No comments. This was just one example. It did not work on any file in our code base. I verified 10 cases where it should annotate but did not.

Is your source code open source? Otherwise if you don't investigate more I have to close this as "cannot reproduce".

Good question. Probably always has been that way. Deleted it and it works fine now. Thanks!