overloading.py icon indicating copy to clipboard operation
overloading.py copied to clipboard

AttributeError: module 'typing' has no attribute 'TypingMeta'

Open Hendiadyoin1 opened this issue 6 years ago • 6 comments

for some reason my program throws this error rooted in this lib. when i try to simply overload the init of my class. Code:

from overloading import overload
import cmath

class Quaternion:
    def __init__(self, r: int, i: int, j: int, k: int):
        self.r = r
        self.i = i
        self.j = j
        self.k = k

    @overload
    def __init__(self, c: complex):
        self.r = c.real
        self.i = c.imag


print(Quaternion(1, 2, 3, 4).r)
print(Quaternion(1 + 2j).r)

Error:

Traceback (most recent call last): File "C:...\Python\Python37\lib\site-packages\overloading.py", line 63, in overload return register(__registry[fname], func) KeyError: 'main.Quaternion.init'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:...\Python\Testing\quaternion.py", line 6, in class Quaternion: File "C:...\Python\Testing\quaternion.py", line 14, in Quaternion def init(self, c: complex): File "C:...\Python\Python37\lib\site-packages\overloading.py", line 65, in overload registry[fname] = overloaded(func) File "C:...\Python\Python37\lib\site-packages\overloading.py", line 151, in overloaded return register(dispatcher, func) File "C:...\Python\Python37\lib\site-packages\overloading.py", line 199, in register signature = get_signature(fn) File "C:...\Python\Python37\lib\site-packages\overloading.py", line 441, in get_signature types = tuple(normalize_type(type_hints.get(param, AnyType)) for param in parameters) File "C:...\Python\Python37\lib\site-packages\overloading.py", line 441, in types = tuple(normalize_type(type_hints.get(param, AnyType)) for param in parameters) File "C:...\Python\Python37\lib\site-packages\overloading.py", line 468, in normalize_type if not typing or not isinstance(type, typing.TypingMeta) or type is AnyType: AttributeError: module 'typing' has no attribute 'TypingMeta'

Hendiadyoin1 avatar Apr 27 '19 15:04 Hendiadyoin1

Same here, python 3.7

fpiedrah avatar Sep 08 '19 14:09 fpiedrah

The downgrade of the typing module helped me (from the python repository) to version 3.5.2.2. You can also forcefully ignore the typing module in the overloading module by assigning typing = None after the 30th line in the file overloading.py, but I think the typing module features will not be available.

Paprikar avatar Mar 21 '20 22:03 Paprikar

such an unfortunately infomation ! we want use python3; this maybe an solution for overload: https://python3-cookbook.readthedocs.io/zh_CN/latest/c09/p20_implement_multiple_dispatch_with_function_annotations.html

tony-is-coding avatar Jun 01 '20 01:06 tony-is-coding

The downgrade of the typing module helped me (from the python repository) to version 3.5.2.2. You can also forcefully ignore the typing module in the overloading module by assigning typing = None after the 30th line in the file overloading.py, but I think the typing module features will not be available.

Same issue here. Downgrading all the way to 3.5 sounds like a major hassle.

kaimingkuang avatar Dec 23 '20 11:12 kaimingkuang

I have the same issue. @bintoro If you ask me, this project should be archived, since it's not in active development and does not work for the newest versions of python.

ImahnShekhzadeh avatar Sep 08 '23 14:09 ImahnShekhzadeh