Skip to content

Latest commit

 

History

History
105 lines (75 loc) · 1.66 KB

checklist.md

File metadata and controls

105 lines (75 loc) · 1.66 KB

Сheck Your Code Against the Following Points

Code Efficiency

Don't compare a variable to 0 if there is no need:

Good example:

if number_of_students:
    pass

Bad example:

if number_of_students != 0:
    pass

Code Style

  1. Use one style of quotes in your code. Double quotes are preferable.
  2. Use ( ) while importing multiple classes/modules:

Good example:

from app.main import (
    KnightWithArmour,
    KnightWithoutArmour,
    SuperHeroKnightWithGun
)

Bad example:

from app.main import KnightWithArmour, \
    KnightWithoutArmour, \
    SuperHeroKnightWithGun
  1. Use descriptive error messages:

Good example:

if error:
    raise CustomError("We have an error on the line 16.")

Bad examples:

if error:
    raise CustomError
if error:
    raise CustomError("CustomError")
  1. Avoid using unnecessary else:

Good example:

def go_to_cinema(condition: bool) -> str:
    if condition:
        return "We are going to the cinema!"
    return "We are not going to the cinema("

Bad example:

def go_to_cinema(condition: bool) -> str:
    if condition:
        return "We are going to the cinema!"
    else:
        return "We are not going to the cinema("
  1. Use annotation, it is a good practice:

Good example:

def multiply_by_2(number: int) -> int:
    return number * 2

Bad example:

def multiply_by_2(number):
    return number * 2

Clean Code

Add comments, prints, and functions to check your solution when you write your code. Don't forget to delete them when you are ready to commit and push your code.