Skip to content

Rules #1

@sobolevn

Description

@sobolevn

Rules to check and implement:

General

  • no nested functions
  • no nested classes (Meta as whitelist)
  • no unused arguments
  • no len(x) == 0 in if conditions
  • no always True checks
  • no raise (without new exception) not within except
  • no raise NotImplemented
  • no __author__
  • no / linebrakes

Complexity

  • too many local variables
  • too many arguments
  • too many branches
  • too many returns
  • too many expressions
  • too many statements
  • too deep nesting

Function calls

  • no exec, eval, and compile
  • no vars(), no dir()
  • no print, pprint
  • no input
  • no globals(), no locals()
  • no short function names

Keywords

  • no global, no nonlocal, no del, no pass

Imports

  • no from some import * aka star-import
  • no from .. import some aka dot import
  • no nested imports
  • no __import__

Classes

  • no return/yield in __init__
  • no self override
  • self is not used
  • first method argument must be cls or self if not staticmethod
  • too few public method (__init__ + one other)
  • too many public methods
  • too many instance attributes
  • no magic methods: __del__
  • no attributes with default None: class Fixture: some_attribute = None

Variables

  • no blacklist variable names: data, result
  • no short variable names

Files

  • no bom
  • no long files, max-file-lines = 600
  • no logic in __init__.py
  • no __{}__ filenames, except __init__ and __main__

mypy

  • follow this pattern: x: List[SomeValue] = [], def cast(element: Element = None) -> str:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions