Anbarryprojects / fastapi-babel

FastAPI babel support pybable tools like translation of text, formatting of dates, times and numbers, and time zones.
MIT License
46 stars 14 forks source link

Add strict formatting and linting, maybe with pre-commit? #7

Closed sina-e closed 2 years ago

sina-e commented 2 years ago

on my first pull request #6 I noticed that the code is not formatted properly, imports are not sorted, and it seems a little inconsistent.

suggestion:

add flake8, black, and isort to the dev requirements. also, pre-commit to format and lint the code.

sina-e commented 2 years ago

I think it's better to set up a dev environment. take a look at PyTitle

Legopapurida commented 2 years ago

Oh right, in this first step we will add stub file for adding type hints, because of python type hint versions we may face with type hint errors in gunicorn web server ( we struggled on it ).

So having a stub file can improve our code healthy.

Legopapurida commented 2 years ago

Also we will add black instead of flake8. Black is much more standard than flake8 as we used.

sina-e commented 2 years ago

I think is best to use black and flake8 together, Black for code formatting, flake8 for linting. also isort for sorting the imports. take a look at this article.

Legopapurida commented 2 years ago

@sina-e I will check this out. thanks to you.

sina-e commented 2 years ago

Oh right, in this first step we will add stub file for adding type hints, because of python type hint versions we may face with type hint errors in gunicorn web server ( we struggled on it ).

what sort of problems did you have with gunicorn and type hinting? (i wasn't talking about type hinting in the original issue, but I'm curious) I didn't see any problems in my last projects.

Legopapurida commented 2 years ago

Python type hint versions 3.10 has difference with 3.7 type hinting.