Skip to content

Failed to overload instance method in Python 3.6 #7

@kylemart

Description

@kylemart

EDIT: Just realized your test suite doesn't cover Python 3.6.X.

I don't have this issue when using Python 3.4.3, but when using Python 3.6.3 I receive OverloadErrors when providing overrides for class instance methods.

Here's a case that gives me an error in the newer version of Python:

Python 3.6.3 (default, Oct  5 2017, 19:38:03) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from overloading import overload
>>> class Test:
...     @overload
...     def m(self, n : int):
...         return n + 1
...     @overload
...     def m(self, n1 : int, n2 : int):
...         return n1 + n2
... 
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/overloading.py", line 63, in overload
    return register(__registry[fname], func)
KeyError: '__main__.Test.m'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in Test
  File "/usr/local/lib/python3.6/site-packages/overloading.py", line 65, in overload
    __registry[fname] = overloaded(func)
  File "/usr/local/lib/python3.6/site-packages/overloading.py", line 151, in overloaded
    return register(dispatcher, func)
  File "/usr/local/lib/python3.6/site-packages/overloading.py", line 205, in register
    .format(dp.__name__, signature.parameters[i]))
overloading.OverloadingError: Failed to overload function 'm': parameter 'self' has an annotation that is not a type.

What's going on?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions