facebook pixelCodiga Analysis Python Rules, category best practice
BACK TO LIST

Python rules

The Codiga Static Analysis engine is powered by the best open-source tools to check your Python code. Make sure your code does not have any security issues and follow design and other best practices. Automate your code reviews today and merge with confidence with Codiga.

C0113

Best practice
Informational

Detect inappropriate use of the not keyword

Learn more

C0121

Best practice
Informational

Check when valid is compared to True, False or None (and can be replaced by simpler expressions)

C0123

Best practice
Warning

Using type() instead of isinstance() for a typecheck.

C0144

Best practice
Informational

Detect when a name contains at least one non-ASCII unicode character

C0200

Best practice
Warning

Consider using enumerate instead of iterating with range and len

C0201

Best practice
Warning

Consider iterating the dictionary directly instead of calling .keys()

C0205

Best practice
Error

Ensure that __slots__ is an iterable and not a base type

C0305

Best practice
Informational

Trailing newlines

C0410

Best practice
Warning

Multiple imports on one line

C0411

Best practice
Warning

Wrong import order

C0412

Best practice
Informational

Imports are not grouped

C0413

Best practice
Informational

Import and code are mixed

C0414

Best practice
Informational

Import alias is same as original package

C0415

Best practice
Warning

Import not put at the top level of the file

R1712

Best practice
Error

Consider using tuple unpacking for swapping variables

R1713

Best practice
Error

Consider using str.join() for concatenating strings from an iterable

R1715

Best practice
Error

Consider using dict.get for getting values from a dict if a key is present or a default if not

R1722

Best practice
Informational

Use sys.exit()

W0401

Best practice
Warning

Use of wildcard imports

W0402

Best practice
Error

Uses of deprecated modules

W0404

Best practice
Warning

Module imported twice

W0511

Best practice
Informational

Use TODO, not FIXME

W0603

Best practice
Warning

Using the global statement

W0612

Best practice
Warning

Unused variable

W0715

Best practice
Error

Passing multiple incorrect arguments to an exception constructor

W1201

Best practice
Warning

Do not use lazy formatting

W1202

Best practice
Warning

Do not use format() in logging function

W1203

Best practice
Error

Use %s in logging function

W1304

Best practice
Error

Unused format argument

W1306

Best practice
Warning

Missing format attribute

W1308

Best practice
Warning

Duplicate string formatting argument

W1309

Best practice
Error

Using an f-string that does not have any interpolated variables

W1401

Best practice
Warning

Anomalous backslash in string

W1501

Best practice
Error

Invalid file open mode

W1503

Best practice
Warning

Redundant use of unit test assert

W1505

Best practice
Warning

Use of deprecated method

W1506

Best practice
Warning

Thread needs the target function

W0237

Best practice
Error

Method parameter has a different name than in the implemented interface or in an overridden method

C0104

Best practice
Error

Disallowed name (e.g. foo, bar, etc)

C0206

Best practice
Warning

Consider iterating with .items()

R1714

Best practice
Error

Use in instead of iterating over value and using equal

C0207

Best practice
Warning

Accessing only the first or last element of str.split() and should be done more efficiently.

C1802

Best practice
Warning

Use implicit boolean with len()

C0208

Best practice
Warning

Use a sequence type when iterating over values When iterating over values, sequence types (e.g., lists, tuples, ranges) are more efficient than sets.

R0203

Best practice
Warning

Consider using a decorator instead of calling staticmethod

R1725

Best practice
Warning

Consider using Python 3 style super() without arguments

R1731

Best practice
Informational

Using the max builtin instead of a conditional improves readability and conciseness

R1732

Best practice
Warning

Consider using 'with' for resource-allocating operations

R1735

Best practice
Informational

Using dict() to create an empty dictionary instead of the literal {}. The literal is faster as it avoids an additional function call.

W0177

Best practice
Warning

An expression is compared to NaNvalues like numpy.NaN and float('nan')

W1406

Best practice
Warning

Used when we detect a string with a u prefix. These prefixes were necessary in Python 2 to indicate a string was Unicode, but since Python 3.0 strings are Unicode by default.

W1512

Best practice
Warning

Using deprecated module

W1513

Best practice
Warning

Use deprecated decorator

E1142

Best practice
Error

'await' should be used within an async function

C2801

Best practice
Warning

Unnecessarily calls dunder method %s. %s.

W1515

Best practice
Warning

Leaving functions creating breakpoints in production code is not recommended.

E2502

Best practice
Informational

Contains control characters that can permit obfuscated code executed differently than displayed.

R1736

Best practice
Warning

Unnecessary list index lookup, use '%s' instead.

W1518

Best practice
Warning

cache will keep all method args alive indefinitely, including 'self'

W0130

Best practice
Warning

Duplicate value in set

W4902

Best practice
Error

Using deprecated method