Categories
Latest version
v1.3.1
Updated on
Jun 16, 2022
Issues
569
Autofix
125
version = 1
[[analyzers]]
name = "python"
enabled = true
dependency_file_paths = [
"requirements/requirements_project.txt"
]
[analyzers.meta]
max_line_length = 100
Anti-pattern
103
Bug risk
209
Documentation
17
Performance
13
Security
69
Style
87
Type check
71
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.
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.
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.