-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[stubtest] Support @final
decorator on methods as well
#14924
Labels
Comments
After working on for a short time, I've noticed several problems:
This happens, because See: >>> def my_final(f):
... f.__final__ = True
... return f >>> class P:
... @my_final
... @property
... def p(self) -> int: ...
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in P
File "<stdin>", line 2, in my_final
AttributeError: 'property' object has no attribute '__final__' But, >>> class St:
... @my_final
... @staticmethod
... def m() -> None: ...
...
>>> St.m
<function St.m at 0x109eeb400>
>>> St.m.__final__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute '__final__'. Did you mean: '__init__'?
>>> St.__dict__['m']
<staticmethod(<function St.m at 0x109eeb400>)>
>>> St.__dict__['m'].__final__
True This needs:
This is quite complicated for a Sunday's evening project, so - please feel free to continue it if someone finds it useful. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After #14922 is merged, I think we can also add a check that this source code has correct stubs:
Right now stubs do not have to add
@final
decorator,stubtest
will allow both versions.The text was updated successfully, but these errors were encountered: