Python

Python

Made by DeepSource
Nullable ManyToManyField found PTC-W0905
Bug risk
Major
Autofix

Having a nullable many-to-many field doesn't do anything. The declaration of a ManyToManyField causes the creation of an intermediate table to hold the relationship. Each relation between the two tables is an entry in this new table. By definition, having no relations between two tables would mean no entries in this table. There's no use of null. Consider removing null=True from this property.

Defining equality for a class without also defining hashability PYL-W1641
Bug risk
Major

In order to conform to the object model, classes that define their own equality method should also define their own hash method, or be unhashable. If the hash method is not defined then the hash of the super class is used. This is unlikely to result in the expected behavior. A class can be made unhashable by setting its __hash__ attribute to None.

Debugger import detected PTC-W0013
Bug risk
Major
Autofix

Debuggers should only be used temporarily and locally. It is highly recommended to remove debug statements in checked-in code.

Invalid metaclass PYL-E1139
Bug risk
Major

The class is using, as a metaclass, something which might be invalid for using as a metaclass.

Do not use bare except, specify exception instead FLK-E722
Bug risk
Minor

Using except without a specific exception can be error prone.

init method converted to generator PYL-E0100
Bug risk
Critical

The __init__() method is required to return nothing, but a yield statement in its body was detected. This will raise a TypeError.

Local variable name referenced before assignment FLK-F823
Bug risk
Critical

Local variables should be defined before they are referenced.

import module shadowed by loop variable FLK-F402
Bug risk
Major

Loop variables should not redefine the name of modules that are imported.

Unary operand used on an unsupported object PYL-E1130
Bug risk
Critical

A unary operand is used on an object which does not support this type of operation. This is an error.

Dictionary key variable name repeated with different values FLK-F602
Bug risk
Major

All dictionary keys should be unique.

Two or more starred expressions in an assignment (a, *b, *c = d) FLK-F622
Bug risk
Critical

There are more than one starred expressions (*x) in an assignment. This is a SyntaxError.

Format string truncated PYL-E1301
Bug risk
Major

The format string was terminated before the end of a conversion specifier. It is recommended to look again and verify if the conversion specifier is given.

Invalid slice index found PYL-E1127
Bug risk
Critical

A slice is indexed with an invalid type. Valid types are ints, slices, and objects with an __index__ method.

Deletion attempted with unsupported object PYL-E1138
Bug risk
Critical

Deletion is supported only for items which implement __delitem__.

Bad first argument given in super() call PYL-E1003
Bug risk
Critical

The first argument to the super() function must be the current class.

Admin class not in app's admin.py PTC-W0903
Bug risk
Major

Admin classes not in an app's admin.py can cause circular import problems throughout a project. This is because registering an admin class implies a call to models.get_apps() which attempts to import every models.py in the project.

Unexpected indentation FLK-E113
Bug risk
Major

A line is indented when it shouldn’t be. Usually this will mean that multiple lines need to be indented at the same level.