mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
The logic is similar to that for instance attributes. Top-level class attributes and methods defined in the class body get the precedence, followed by class attributes defined with assignments in @classmethods unless the latter would resolve to the same assignments as in cls.attr = cls.attr + 1 finally, we scan through all other class methods resolving the name to the first definition inside one of them. So far, I intentionally didn't expose such attributes in findClassAttribute() or getClassAttributes() because users of these methods assume that this API considers only attributes defined immediately in the class body. Adding extra definitions from class methods might break these usages. I had to update the inspection about typing.Final, because it relied on the fact that resolve() on assignment targets on class objects can lead only to those top-level class attributes, where type hints are normally located, but now it can lead to assignments to a qualified attribute inside a containing class method. GitOrigin-RevId: 0ca5bdaa4efca127ac187e822a49df6795e1028a
7 lines
118 B
Python
7 lines
118 B
Python
class C:
|
|
@classmethod
|
|
def m(cls):
|
|
cls.attr = 42
|
|
print(cls.attr)
|
|
# <ref>
|
|
|