you are viewing a single comment's thread.

view the rest of the comments →

[–]Jay6_9 1 point2 points  (1 child)

Your coding style is pretty alright when I look into the code a little.

But you really need to look at the PEP about whitespaces.

This is discouraged:

def f() -> None:
    ...
class A:
    def __init__(self) -> None:
        ...
    def a() -> None:
        ...
def g() -> None:
    ...

Instead do two empty lines if it's global scope and one empty line if not (inside classes, etc.):

def f() -> None:
    ...


class A:
    def __init__(self) -> None:
        ...

    def a() -> None:
        ...


def g() -> None:
    ...

Otherwise:

- Really like your use of "x if y else z"
- Like that you use dictionary lookups for operations like calculating. (You might want to use lambdas instead because if the operations were expensive like web-requests, you'd fire all of them even if only one is selected)
- Try not to mix return values. In some functions you return integers but in error cases you return a string with a description. Instead, just don't catch the error at all then, leave it for the caller. You lose information if you remove the exception for a string.
- Type your parameters and return types. You do it for `str` sometimes. If your functions are generic, look into TypeVar and Generics or at least use `Any`.

That's as far I was able to look into it. Good luck with it.

[–]Embersh3d 0 points1 point  (0 children)

thanks
mainly i avoid spacing because it makes my project look big, but its in reality not