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

Make return type implicitly None for type checked __init__ and __init_subclass__ #5677

Merged
merged 8 commits into from Oct 1, 2018

Conversation

Projects
None yet
3 participants
@onlined
Contributor

onlined commented Sep 26, 2018

Implements #604 (comment).

onlined added some commits Sep 26, 2018

@@ -407,6 +406,10 @@ def _visit_func_def(self, defn: FuncDef) -> None:
add_symbol = False
if add_symbol:
self.type.names[defn.name()] = SymbolTableNode(MDEF, defn)
if defn.type is not None and defn.name() in ('__init__', '__init_subclass__'):

This comment has been minimized.

@gvanrossum

gvanrossum Sep 26, 2018

Member

Are you sure this works with overloads and decorated methods? Please add tests to verify that.

Also perhaps it should only work inside a class definition?

This comment has been minimized.

@ilevkivskyi

ilevkivskyi Sep 26, 2018

Collaborator

I think one needs similar check at least in visit_overloaded_func_def.

This comment has been minimized.

@onlined

onlined Sep 26, 2018

Contributor

@gvanrossum It works only inside a class definition.
@gvanrossum @ilevkivskyi You are right, I will find a way to extend behavior.

Show resolved Hide resolved mypy/semanal.py Outdated
@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 26, 2018

Can you also add a test for overloading?

@onlined

This comment has been minimized.

Contributor

onlined commented Sep 26, 2018

I'm on it, but I can say that this change works with overloading too.

onlined added some commits Sep 26, 2018

@onlined

This comment has been minimized.

Contributor

onlined commented Sep 27, 2018

@gvanrossum It may be good to add tests for explicit Any return type, what do you think about it?

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 27, 2018

@gvanrossum It may be good to add tests for explicit Any return type, what do you think about it?

Yes, please.

onlined added some commits Sep 27, 2018

@onlined

This comment has been minimized.

Contributor

onlined commented Sep 28, 2018

I think this PR is ready to merge.

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 28, 2018

@gvanrossum gvanrossum merged commit 9cd3b0f into python:master Oct 1, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Oct 1, 2018

Done (sorry for the delay). Thanks for fixing this long-standing issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment