Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Support return value annotations in functions #88

Closed
wants to merge 1 commit into from
Closed

Support return value annotations in functions #88

wants to merge 1 commit into from

Conversation

pchaigno
Copy link
Contributor

This pull request adds support for return value annotations in functions (as requested in #68) and fixes an error reported in #86.

def init(self, int = 3) -> None :
        """Construct semantic analyzer.
        """
        self.pyversion = pyversion

def visit_file(self, file_node: MypyFile, fnam: str) -> None:
        self.errors.set_file(fnam)
        self.errors.set_ignored_lines(file_node.ignored_lines)
        self.cur_mod_node = file_node

See the fix in Lightshow.

It loses the invalid.illegal scope for function headers without a terminating :. I couldn't find a way to keep it. Though, most of the time, you can still clearly see that it's missing.

The semi-colon marking the end of a function header is
not necessary preceded by a closing parenthesis
@berdario
Copy link
Contributor

berdario commented Oct 2, 2015

re: Isn't #95 the same as this one?

I'm not quite sure about your changes (otoh, I haven't tried to run them yet... but I don't know how to do it, either... I know only how to run tests, and this PR doesn't make any change to tests): you removed stuff from the regexps, so I'm a bit confused as how this could actually parse correctly the -> token needed for function annotations

Is the test that I wrote in #95 potentially useful to be reused?
Anyhow, the scope for that other PR was to handle all function annotations, not only return value annotations

Good to know that you're working on it :)

@pchaigno
Copy link
Contributor Author

pchaigno commented Oct 2, 2015

re: Isn't #95 the same as this one?

But mine's older 😜

Is the test that I wrote in #95 potentially useful to be reused?
Anyhow, the scope for that other PR was to handle all function annotations, not only return value annotations

I'll try to take a look at this over the week-end (I'll add on your PR if it's more complete than mine ;).

@berdario
Copy link
Contributor

berdario commented Oct 2, 2015

Sure

Since you seem to be more knowledgeable about this project than me:

Do you have any pointers/documentation? The README is pretty laconic

@pwaller
Copy link

pwaller commented Jun 4, 2016

@pchaigno any chance of getting this in? The highlighting is completely broken to the point of distraction for code with return annotations at the moment.

@berdario
Copy link
Contributor

berdario commented Jun 4, 2016

@pwaller
Just install MagicPython

https://github.com/MagicStack/MagicPython

See also

#109

@50Wliu 50Wliu closed this in #228 Jan 25, 2018
@pchaigno pchaigno deleted the fix-function-header branch January 25, 2018 21:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants