You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide return type hint for the function: init. If the function does not return a value, please provide the type hint as: def function() -> None:
Adding -> None have not sense, since this is a special method and it always returns None. Aslo this creates noise in code and even decreases readability when it's the reason for extra line breaks.
For example, this line fits without annotation and is split into 3 lines with it.
The init method is a special method in Python used to initialize objects of a class. It does not return a value and should not have a return type hint. However, the method signature can have type hints for the parameters it accepts.
In this example, the init method takes two arguments, arg1 which is of type str, and arg2 which is of type int. The method does not return anything and is annotated with -> None. However, this annotation is not necessary and can be omitted.
Just to mention, PEP 484 stats that __init__ should be annotated with -> None:
(Note that the return type of __init__ ought to be annotated with -> None. The reason for this is subtle. If __init__ assumed a return annotation of -> None, would that mean that an argument-less, un-annotated __init__ method should still be type-checked? Rather than leaving this ambiguous or introducing an exception to the exception, we simply say that __init__ ought to have a return annotation; the default behavior is thus the same as for other methods.)
@Cjkjvfnby For the mentioned case, you can put a comma after the last parameter and Black puts every parameter on a single line like:
Feature description
Adding
-> None
have not sense, since this is a special method and it always returns None. Aslo this creates noise in code and even decreases readability when it's the reason for extra line breaks.For example, this line fits without annotation and is split into 3 lines with it.
The text was updated successfully, but these errors were encountered: