Categories

Programming language

Latest version

v1.3.1

Updated on

Jun 16, 2022

Issues

569

Autofix

125

Sample configuration


version = 1

[[analyzers]]
name = "python"
enabled = true
dependency_file_paths = [
  "requirements/requirements_project.txt"
]

  [analyzers.meta]
  max_line_length = 100

Stats


Anti-pattern

103

Bug risk

209

Documentation

17

Performance

13

Security

69

Style

87

Type check

71

Issues


View all
File opened without the `with` statementPTC-W0010
Anti-pattern

Opening a file using with statement is preferred as function open implements the context manager protocol that releases the resource when it is outside of the with block. Not doing so requires you to manually release the resource.

Found `yield` statement inside a comprehensionPTC-W0025
Bug risk

Do not use yield inside a comprehension as it will return a generator object. Use a generator expression instead.

Note: Use of yield inside a comprehension was allowed till Python 3.7 but is a syntax error from Python 3.8 onwards.

Explicit exception raised in the assert messagePTC-W0032
Bug risk
Autofix

Raising a built-in or a custom exception when assert fails is ineffective. Asserts always raise an AssertionError, making the provided exception which the user is expecting useless. This may lead to runtime errors if this detail is not understood during the exception handling. It is therefore recommended to use if to check the condition and raise the expression explicitly if something is not right.

Debugger activation detectedPTC-W0014
Bug risk
Autofix

Debuggers should only be used temporarily and locally. It is highly recommended not to leave debug statements in checked-in code. This may cause your application to have unintended side-effects.

I/O operation on a closed file detectedPTC-W0021
Bug risk

The I/O operation is being performed on a resource that is closed. This will lead to a runtime error. It is recommended to perform I/O operation on files inside with blocks, as the file is automatically closed when the scope of with ends.