A
A
albertalexandrov2018-10-09 18:44:40
Python
albertalexandrov, 2018-10-09 18:44:40

What does the syntax "cls: 'BasePlugin'" mean?

Hi all!
I would not ask a question here if I knew how to formulate it for a search engine. Therefore, do not judge.
I met a syntax that is equally unknown to me ( https://habr.com/company/binarydistrict/blog/422409/):

def __new__(mcs, name, bases, attrs):  
        cls: 'BasePlugin' = super().__new__(mcs, name, bases, attrs)

In the second line, the part with is not clear cls:
. Please tell me what it is.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-10-09
@albertalexandrov

This is Type Hints . Read as "Assign to variable cls of type BasePlugin the result of calling the __new__ method of the superclass".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question