Skip to content
Arjun Nemani edited this page Dec 19, 2016 · 4 revisions

UIP stands for UIP is Pretty

Rules:

  • Run coala over your code.
  • Write unit tests for all your implementations. Then run pytest over your code.
  • Be sure to check that you have 100% code coverage too. This could be checked by pytest --cov.
  • Do not write your own configuration for pytest with pytest.ini or setup.cfg.

Python Style Guide:

We are PEP8 Compliant.

Imports:

  • Avoid module name collisions. Never use relative names in imports.
  • Each import should be on a separate line.
  • Even if the module is in same package, use full package name. This prevents importing same package twice.
  • Import each module using the full pathname location of the package.
  • We use camel casing while writing new packages.
  • Modulate your code as much as possible.

Exceptions:

  • Use them wisely.
  • Never use catch all or catch with Exception or StandardError. We need to have knowledge upon the specific type of Exception handled.

Variables:

  • Use snake_casing for variable names.
  • Avoid Global variables as much as possible.

Classes:

  • Use Title Case for class names.
  • Explicit inherit for object is not preferred.

General:

  • Avoid over complexities in lines of code.
  • Reduce cyclomatic complexity.
  • Avoid using True and False explicitly. Use implicit False as much as possible.
  • A very strict not to semicolons ;.
  • Also, the use of Shebang #! is not preferable.
  • One statement per line.
  • Use % for string formatting. Rather than concatenation with +.
  • Maximum line length is 80 characters.
  • Whitespaces are used as per PEP8.
  • Indent your code blocks with 4 spaces.

Docstrings & Comments: (We follow pydocstyle)

  • Docstrings are enclosed with Triple quotes(""") only.
  • Indent with one level for docstrings.
  • Use comments on a required scale. Remember that writing readable code is important.

Casing examples

moduleName, packageName, ClassName, method_name, ExceptionName, function_name, GLOBAL_CONSTANT_NAME, global_var_name, instance_var_name, function_parameter_name, local_var_name.
Clone this wiki locally