serge-sans-paille / beniget

Extract semantic information about static Python code
BSD 3-Clause "New" or "Revised" License
69 stars 21 forks source link

AnnAssign links the target as beeing the def of dannotation #63

Closed tristanlatr closed 10 months ago

tristanlatr commented 1 year ago

The little it of code seems strange to https://github.com/serge-sans-paille/beniget/blob/master/beniget/beniget.py#L769-L772

I think the annotation should not be added to the uses of the target of the assignment. It's like saying "the assign target is where it's annotation is defined", which doesn't make any sens to me.

That way we could cleanup the extra lambda/None values in the _defered_annotations stack as well. (we need it for #72

Tell me what you think, @serge-sans-paille.

tristanlatr commented 1 year ago

Here is a failing test case:

    def test_annotation_def_is_not_assign_target(self):
        code = 'from typing import Optional; var:Optional'
        self.checkChains(code, ['Optional -> (Optional -> ())', 
                                'var -> ()'])
tristanlatr commented 1 year ago

Any opinion on this behavior @serge-sans-paille ?