Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add self argument if nested function in method #6769

Conversation

@onlined
Copy link
Contributor

commented May 6, 2019

Fix #5806.

Fix
@@ -513,6 +516,7 @@ def do_func_def(self, n: Union[ast3.FunctionDef, ast3.AsyncFunctionDef],
func_type.definition = func_def
func_type.line = lineno

retval: Union[FuncDef, Decorator]

This comment has been minimized.

Copy link
@gvanrossum

gvanrossum May 6, 2019

Member

Because mypy needs to run with Python 3.5, you can't use this PEP-526 syntax here yet (which is 3.6 or later only). To fix this, use a type comment on the first line that assigns to retval.

This comment has been minimized.

Copy link
@onlined

onlined May 6, 2019

Author Contributor

Sorry, fixing now.

@gvanrossum
Copy link
Member

left a comment

I'm basically happy with this -- one nit and a suggestion for an extra test.

@@ -249,6 +249,8 @@ def __init__(self,
is_stub: bool,
errors: Errors) -> None:
self.class_nesting = 0

This comment has been minimized.

Copy link
@gvanrossum

gvanrossum May 6, 2019

Member

Shouldn't you delete this variable? It's no longer updated.

This comment has been minimized.

Copy link
@onlined

onlined May 6, 2019

Author Contributor

Yes, I forgot it.

@@ -737,6 +737,14 @@ class A:
main:6: error: Incompatible types in assignment (expression has type "int", variable has type "A")
main:8: error: Argument 1 to "g" has incompatible type "A"; expected "int"

[case testNestedFunctionInMethodWithTooFewArgumentsInTypeComment]

This comment has been minimized.

Copy link
@gvanrossum

gvanrossum May 6, 2019

Member

Perhaps you could also add a test for a few other configurations of the stack, e.g. a method inside a class inside a method (i.e. ['C', 'F', 'C', 'F'])?

onlined added some commits May 6, 2019

@gvanrossum

This comment has been minimized.

Copy link
Member

commented May 6, 2019

Thanks! Ready to be merged once the tests pass.

@gvanrossum gvanrossum merged commit 9f823a7 into python:master May 6, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.