diff --git a/pylint.html b/pylint.html index 2f476c4..7cd5854 100644 --- a/pylint.html +++ b/pylint.html @@ -1,266 +1,407 @@ - - + + - Pylint, Warnings e Correções + Pylint, Warnings e Correções - + - - + + - + - - + + - - + + - - + + - + - - - - -
- -
-
-

Pylint, Warnings e Correções

-
- -
-
-

missing-docstring

-
- -
-

O que é o erro:

-
-


+
+div.code {
+    font-size: 150%
+}
+        
+    
+
+    
+        
+ +
+
+

Pylint, Warnings e Correções

+
+ +
+
+

missing-docstring

+
+ +
+

O que é o erro

+
+


 def funcao(valor):
-	return valor * 2
-							

-
-
- -
-

Solução:

- -

Documente suas funções!

-
-
- -
-
-

wildcard-import

-
-
- -
-
-

unused-import

-
-
- -
-
-

unused-argument

-
-
- -
-
-

bare-except

-
-
- -
-
-

no-self-use

-
-
- -
-
-

old-style-class

-
-
- -
-
-

super-on-old-class

-
-
- -
-
-

no-init

-
-
- -
-
-

super-init-not-called

-
-
- -
-
-

attribute-defined-outside-init

-
-
- -
-
-

abstract-method

-
-
- -
-
-

arguments-differ

-
-
- -
-
-

no-member e maybe-no-member

-
-
- -
-
-

no-value-for-parameter

-
-
- -
-
-

protected-access

-
-
- -
-
-

too-few-public-methods

-
-
- -
-
-

too-many-ancestors

-
-
- -
-
-

too-many-arguments

-
-
- -
-
-

too-many-branches

-
-
- -
-
-

too-many-instance-attributes

-
-
- -
-
-

too-many-lines

-
-
- -
-
-

too-many-locals

-
-
- -
-
-

too-many-public-methods

-
-
- -
-
-

too-many-statements

-
-
- -
-
-

invalid-name

-
-
- -
-
-

star-args

-
-
-
-
- - - - - - - + return valor * 2 +

+
+
+ +
+

Solução

+ +

Documente suas funções!

+
+
+ +
+
+

wildcard-import

+
+ +
+

O que é o erro

+
+


+from module import *
+                            

+
+
+ +
+

Solução

+ +

Importe apenas as funções módulos que são usados.

+
+ +
+

Por que não usar "import *"

+ +
    +
  • O módulo pode ter código não protegido por + função, classe ou if __name__ == '__main__'
  • +
  • Poluíção do namespace.
  • +
  • Módulo pode redefinir uma função presente no + módulo atual.
  • +
+
+
+ +
+
+

unused-import

+
+ +
+

O que é o erro

+ +
+


+from module import function
+                            

+
+ +

(E function() não é usado em lugar algum.)

+
+ +
+

Solução

+ +

Remova o import.

+
+ +
+

Dica!

+ +

Quebrar imports em várias linhas facilita correção desse + tipo de problema.

+ +
+


+from module import func1
+from module import func2
+                            

+
+
+
+ +
+
+

unused-argument

+
+ +
+

O que é o erro

+ +
+


+def func(arg1, arg2):
+    return arg1 * 2
+                            

+
+
+ +
+

Solução

+ +
    +
  • Remova o parâmetro desnecessário
  • +
  • Altere o parâmetro para "_"
  • +
+
+ +
+

Corner case

+ +
+


+def addSeven(foo): # "Unused argument 'foo'"
+    foo += [7]
+                            

+
+ +

O problema é a questão de referência para objetos + mutáveis. O código em si está errado.

+
+
+ +
+
+

bare-except

+
+ +
+

O que é o erro

+ +
+


+try:
+   func()
+except Exception e:
+   pass
+                            

+
+
+ +
+

Solução

+ +

Capture apenas as exceções que você sabe lidar.

+
+
+ +
+
+

no-self-use

+
+ +
+

O que é o erro

+ +
+


+class A(object):
+    def func(self, a):
+        return a * 2
+                            

+
+
+ +
+

Solução

+ +

A solução mais "correta" é tirar a função da classe e deixar + fora do objeto.

+ +

Não sendo possível, + # pylint:disable=no-self-use antes da função. +

+
+
+ +
+
+

old-style-class

+
+
+ +
+
+

super-on-old-class

+
+
+ +
+
+

no-init

+
+
+ +
+
+

super-init-not-called

+
+
+ +
+
+

attribute-defined-outside-init

+
+
+ +
+
+

abstract-method

+
+
+ +
+
+

arguments-differ

+
+
+ +
+
+

no-member e maybe-no-member

+
+
+ +
+
+

no-value-for-parameter

+
+
+ +
+
+

protected-access

+
+
+ +
+
+

too-few-public-methods

+
+
+ +
+
+

too-many-ancestors

+
+
+ +
+
+

too-many-arguments

+
+
+ +
+
+

too-many-branches

+
+
+ +
+
+

too-many-instance-attributes

+
+
+ +
+
+

too-many-lines

+
+
+ +
+
+

too-many-locals

+
+
+ +
+
+

too-many-public-methods

+
+
+ +
+
+

too-many-statements

+
+
+ +
+
+

invalid-name

+
+
+ +
+
+

star-args

+
+
+
+
+ + + + + + + + +