Python

Python

Made by DeepSource

Categories

Programming language

Latest version

v2.13.25

Updated on

Aug 9, 2024


Total issues

577

Autofix

145

Sample configuration

version = 1

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

  [analyzers.meta]
  max_line_length = 100

Stats


Anti-pattern

103

Bug risk

210

Documentation

17

Performance

17

Security

74

Style

85

Type check

71

Issues


View all
File opened without the with statement PTC-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 comprehension PTC-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 message PTC-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 detected PTC-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 detected PTC-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.