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

overrides is incompatible with nuitka #111

Open
bersbersbers opened this issue Feb 10, 2023 · 1 comment
Open

overrides is incompatible with nuitka #111

bersbersbers opened this issue Feb 10, 2023 · 1 comment

Comments

@bersbersbers
Copy link

bersbersbers commented Feb 10, 2023

(Cross-posted to Nuitka/Nuitka#2048 since I have no idea which instance may be best able to fix it.)

This code runs find in python but not after building with nuitka 1.4.4 on Python 3.10: (I think I remember it works after building with pyinstaller.)

"""bug.py"""
from overrides import override

class A:
    def hello(self) -> None:
        print("A")

class B(A):
    @override
    def hello(self) -> None:
        print("B")

b = B()
b.hello()
$ pip install nuitka overrides
$ python bug.py
B
$ python -m nuitka bug.py
...
Nuitka:INFO: Successfully created 'bug.bin'.
$ ./bug.bin
Traceback (most recent call last):
  File "/mnt/c/code/bug.py", line 8, in <module>
    class B(A):
  File "/mnt/c/code/bug.py", line 9, in B
    @override
  File "/home/bers/.local/lib/python3.10/site-packages/overrides/overrides.py", line 143, in override
    return _overrides(method, check_signature, check_at_runtime)
  File "/home/bers/.local/lib/python3.10/site-packages/overrides/overrides.py", line 172, in _overrides
    raise TypeError(f"{method.__qualname__}: No super class method found")
TypeError: B.hello: No super class method found
@bersbersbers
Copy link
Author

To me, a potential fix doesn't look too difficult:

Replace

for super_class in _get_base_classes(sys._getframe(3), global_vars):

by something along these lines:

    super_classes = _get_base_classes(sys._getframe(3), global_vars)
    if not super_classes:  # fix for Nuitka
        return method
    for super_class in super_classes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant