v2.13.25
Aug 9, 2024
577
145
version = 1
[[analyzers]]
name = "python"
dependency_file_paths = [
"requirements/requirements_project.txt"
]
[analyzers.meta]
max_line_length = 100
Anti-pattern
103
Bug risk
210
Documentation
17
Performance
17
Security
74
Style
85
Type check
71
with
statement PTC-W0010Opening 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.
yield
statement inside a comprehension PTC-W0025Do 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.
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.
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.
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.