logo

... flake8.


While your program may work functionally, it may still be hard to maintain if the style of it is messy. So it would be nice to automated code style. A favourable tool for that the flake8 ecosystem.


Episode Notes

This is the code.py file that we start with;

import pandas as pd
from numpy import *

settings = {"a": 1, "b": 2, "c": 3, "a": 2}

def fibonachi( s1, s2, n ):
    """
    calculates the fibonachi sequence 
    with given custom numbers
    """
    result = [s1 , s2]
    for i in range( n ):
        s1, s2 = s2, s1 + s2
        result.append(s2)
    return result 

def fibonachi_standard(n):
    """
    calculates the standard fibonachi sequence
    """
    return Fibonachi(s1=1, s2=2, n)

We then run the following;

flake8 code.py

This gives us a list of errors and we remove them one by one.

settings = {"a": 1, "b": 2, "c": 3}

def fibonachi(s1, s2, n):
    """
    calculates the fibonachi sequence 
    with given custom numbers 
    """
    result = [s1, s2]
    for i in range(n):
        s1, s2 = s2, s1 + s2
        result.append(s2)
    return result


def fibonachi_standard(n):
    """
    calculates the standard fibonachi sequence 
    """
    return fibonachi(s1=1, s2=2, n)

Feedback? See an issue? Feel free to mention it here.

If you want to be kept up to date, consider getting the newsletter.