Python

Python

By DeepSource

Nullable ManyToManyField found PTC-W0905
Bug risk
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

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.

raising NotImplemented is not allowed FLK-F901
Bug risk
Autofix

While returning NotImplemented would be fine, raising it doesn't work and will cause a TypeError because NotImplemented is not an exception type.

Debugger import detected PTC-W0013
Bug risk
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

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

Using except without a specific exception can be error prone.

init method converted to generator PYL-E0100
Bug risk

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

Local variables should be defined before they are referenced.

import module from line N shadowed by loop variable FLK-F402
Bug risk

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

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

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

All dictionary keys should be unique.

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

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

Format string truncated PYL-E1301
Bug risk

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

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

Deletion is supported only for items which implement __delitem__.

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

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

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

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.