Title: Unsubscriptable "cls" and missing "bases" and "classdict" warning from Pylint
Tags: python,enums,pylint,metaclass

Question: I have create a metaclass based on the EnumMeta, in order to add "contains" functionality to my derived Enum class. Here is my code:
class MetaEnum(EnumMeta):
    def __contains__(cls, item_to_check):
        try:
            if isinstance(item_to_check, str):
                dummy = cls[item_to_check.upper()] 
            else:
                cls(item_to_check)
        except (KeyError, ValueError):
            return False
        return True

When I run Pylint I get three warnings:

E1136: Value 'cls' is unsubscriptable (unsubscriptable-object) at the following line:
dummy = cls[item_to_check.upper()] 

E1120: No value for argument 'bases' in constructor call (no-value-for-parameter) and E1120: No value for argument 'classdict' in constructor call (no-value-for-parameter)at the following line:
cls(item_to_check)


The code is performing what is supposed to, as it is. Here is an example:
from enum import Enum, EnumMeta

class MetaEnum(EnumMeta):
    def __contains__(cls, item_to_check):
        try:
            if isinstance(item_to_check, str):
                dummy = cls[item_to_check.upper()] 
            else:
                cls(item_to_check)  
        except (KeyError, ValueError):
            return False
        return True

class BaseEnum(Enum, metaclass=MetaEnum):
  pass


class Platform(BaseEnum):
  ORACLE = 'ORACLE'
  MSSQL = 'MSSQL'


platform: str = 'ORACLE'
if platform not in Platform:
    print('Platform variable is not in enumeration.')
else:
    print('Platform variable found in enumeration!')

platform: str = 'ORACLEE'
if platform not in Platform:
    print('Platform variable is not in enumeration.')
else:
    print('Platform variable found in enumeration!') 

And I can supress the warnings with the "# pylint: disable" directives:
"# pylint: disable=unsubscriptable-object" and  "pylint: disable=no-value-for-parameter".
But I am new to Python so I am not sure if the above are false positives or the code could be better written to "satisfy" Pylint too.
Is there a way to address the aforementioned Pylint warnings?

Answer: Linters and other tools are based on static type checking - while metaclasses have effects in runtime.
They even try to incorporate some "understanding" of metaclasses on some of the tools: for example, in this case, PyLint assumes you are trying to create a new instance of the class __contains__ is defined in, and does not know that cls there refers to a class created using it.
In short: the only thing to do is to mark this code as not-checkable with pylint and other tools you are using, if possible.  If not possible, just ignore their output.
When we are at a static typing error, there are, sometimes, some convolutions that could be made that would silence the tool errors - but in this case, the tool is just blind to what you are doing - nothing done to the code would help, and trying to conform to the tool would just ultimately lead you to not write this code, and use a standalone function to check for containment, callable somewhat like check_if_enum_contains(enumclass, candidate).