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

Fix overload resolution for metaclass #3511

Merged
merged 2 commits into from Jun 26, 2017

Conversation

Projects
None yet
3 participants
@elazarg
Contributor

elazarg commented Jun 8, 2017

Fix #3452.

Show outdated Hide outdated test-data/unit/check-classes.test
reveal_type(f(e2)) # E: Revealed type is 'builtins.int'
[out]
main:6: error: An overloaded function outside a stub file must have an implementation

This comment has been minimized.

@elazarg

elazarg Jun 8, 2017

Contributor

Is this a bug?

@elazarg

elazarg Jun 8, 2017

Contributor

Is this a bug?

This comment has been minimized.

@ilevkivskyi

ilevkivskyi Jun 8, 2017

Collaborator

No, there must be an implementation (or make this in a .pyi file in test).

@ilevkivskyi

ilevkivskyi Jun 8, 2017

Collaborator

No, there must be an implementation (or make this in a .pyi file in test).

This comment has been minimized.

@elazarg

elazarg Jun 8, 2017

Contributor

But there is

@elazarg

elazarg Jun 8, 2017

Contributor

But there is

This comment has been minimized.

@ilevkivskyi

ilevkivskyi Jun 8, 2017

Collaborator

This is not how overloads work. PEP 484:

In regular modules, a series of @overload-decorated definitions must be followed by exactly one non-@overload-decorated definition

@ilevkivskyi

ilevkivskyi Jun 8, 2017

Collaborator

This is not how overloads work. PEP 484:

In regular modules, a series of @overload-decorated definitions must be followed by exactly one non-@overload-decorated definition

This comment has been minimized.

@elazarg

elazarg Jun 8, 2017

Contributor

OK, sorry. I will add one.

@elazarg

elazarg Jun 8, 2017

Contributor

OK, sorry. I will add one.

@JukkaL

Looks good, just a few ideas for test cases.

Show outdated Hide outdated test-data/unit/check-classes.test
class EM(type): pass
class E(metaclass=EM): pass
@overload

This comment has been minimized.

@JukkaL

JukkaL Jun 20, 2017

Collaborator

It would be nice to have a few more test cases:

  • Test two overload variants which have two different metaclasses as argument types, and overloading based on metaclass.
  • Test calling the overloaded function with a str argument (results should be str).
@JukkaL

JukkaL Jun 20, 2017

Collaborator

It would be nice to have a few more test cases:

  • Test two overload variants which have two different metaclasses as argument types, and overloading based on metaclass.
  • Test calling the overloaded function with a str argument (results should be str).

@JukkaL JukkaL self-requested a review Jun 20, 2017

@JukkaL JukkaL self-assigned this Jun 20, 2017

@JukkaL

JukkaL approved these changes Jun 26, 2017

Looks good now. Thanks for fixing this!

@JukkaL JukkaL merged commit 53c6e58 into python:master Jun 26, 2017

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