Discussion:
[Pydev-users] Code analysis and metaclasses
Malte Forkel
2017-06-17 10:51:29 UTC
Permalink
Hi,

when running a code analysis in PyDev 3.8.0, I noticed that
- using 'cls' instead of 'self' as the name of the first parameter of a
metaclass instance method is flagged as an error (but see example in PEP
3115)
- metaclass instance methods are not always recognized as attributes of
instances of the metaclass. Calling such method for an imported class is
flagged as an error

Here is minimal example:


meta_ca1.py:

class MyMeta(type):
def create_instance(cls): # flagged as error
return 42

class MyClass(metaclass=MyMeta):
pass

print(MyClass.create_instance()) # not flagged as error


meta_ca2.py

from .meta_ca2 import MyClass

print(MyClass.create_instance()) # flagged as error


Am I missing something?

Malte

Loading...