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
nuitka
is incompatible with overrides
#2048
Comments
It seems the Now it will be an interesting puzzle to solve this. Effectively, However, outside of Nuitka commercial I do not see myself doing this for a while. With somebody willing to pay my time there, no problem, but right now there is more important stuff to do otherwise. |
No problem at all! I can easily fallback by such a construct here: if whatever:
from overrides import override
else:
F = TypeVar("F", bound=Callable)
def override(method: F) -> F:
return method Is there an ideal way to check that my code has been/is being compiled by Nuitka? |
This looks then more like something the anti-bloat engine could do instead. Just replace If that is functionality equivalent (I think doc strings will not be copied), then we can get away with that and call it a day. Will you create a PR? |
This looks like a good solution, too - I'll keep that in mind. In the meantime, I think I found a good fix to |
Yes, we can do that, or even replace the whole function. You can experiment with this:
I will try that later, just replaces the whole function with that lambda. We do similar for other software I took this from |
I feel that's probably already the solution and of course could be in a next hotfix once confirmed. |
Alright, will check tomorrow. Not sure yet if we need to change |
The use of screenshots clearly indicates that working with text is not your strong suit. Eventually I will try myself. |
I think you didn't include overrides in the compilation, when accelerated mode won't do unless told, other than say standalone mode, and then of course anti-bloat will not use it. Also the module name is This is probably way too black magic currently. |
I think I did, otherwise I wouldn't get
Do you mean the decorator name? Actually, there is
I agree, compare #2048 (comment) |
I'm not at all sure should I merge the PR to overrides mkorpela/overrides#112 it basically silently just fails the whole operation.
Because it checks override during class loading and that is the place where the super class is found from. I know that Python 3.12 will have a override decorator in types https://peps.python.org/pep-0698/ |
I agree - would it help if we made the check more specific? I noticed that
No idea, unfortunately.
Interesting, thank you! Maybe Nuitka can (has to?) consider that one as well, and in effect consider both |
For the record, it will be in Python 3.12 via python/cpython#101564. Until then it is also available via python/typing_extensions#78. Since that "official" decorator is defined to not have any runtime effects, I would guess Nuitka does not have to care about either of those. Whether |
For whatever feature is added to Python, there is always a backport available, that Nuitka gets to support. I doubt it will be different in this case, otherwise the feature will be unavailable for use in practically all libraries. |
I understand that.
Well, what is different in this case is that, as I wrote, from typing_extensions import override
class BaseClass:
def hello(self) -> None:
print(self)
class Class(BaseClass):
@override
def hello(self) -> None:
print(self)
c = Class()
c.hello() |
That's good. For that |
Great!
Not sure I understand the difference to be honest. I'd say both, I guess. Check these two links for current implementations: |
I had to make a hotfix the other day, and the change is actually part of 1.4.6 because it's only config. |
(Cross-posted from mkorpela/overrides#111 since I have no idea which instance may be best able to fix it.)
This code runs find in
python
but not after building withnuitka
1.4.4 on Python 3.10:The text was updated successfully, but these errors were encountered: