Menu

Metaclasses and static analyzer

Ryan Seiff
2011-01-13
2013-03-15
  • Ryan Seiff

    Ryan Seiff - 2011-01-13

    I am curious if there is any support for exceptions to the static analyzer for metaclasses. I have some code that looks like the following:

    class MetaClass(type):
        def __call__(cls, *args, **kwargs):
            pass
    

    PyDev highlights __call__ with an error of "should have self as first parameter.", but that is not the general "pythonic" pattern followed with metaclasses. I know that I can #@NoSelf the line, but that creates extra clutter that I would like to avoid.

    Does PyDev have any support for different rulesets with metaclasses? If the static analyzer is not able to determine what classes are actually metaclasses, I would find marking up the class definition with an #@IsMetaclass comment preferable to #@NoSelf'ing each method definition. Would this be a reasonable solution?

    -Ryan

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-01-13

    I guess it could detect that your class is already a subclass of 'type' and properly handle the __call__ in that case… please enter a feature request for that.

    Cheers,

    Fabio

     
  • Ryan Seiff

    Ryan Seiff - 2011-01-14

    Adding it now. Thanks Fabio.

    -Ryan

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.