microblog icon indicating copy to clipboard operation
microblog copied to clipboard

Addition of code linting would be nice

Open golharam opened this issue 1 year ago • 1 comments

golharam avatar Nov 16 '24 14:11 golharam

You can lint the code yourself very easily:

> pip install flake8
> flake8 app/*
app/__init__.py:99:1: F401 'app.models' imported but unused
app/__init__.py:99:1: E402 module level import not at top of file
app/api/__init__.py:5:1: F401 'app.api.users' imported but unused
app/api/__init__.py:5:1: F401 'app.api.errors' imported but unused
app/api/__init__.py:5:1: F401 'app.api.tokens' imported but unused
app/api/__init__.py:5:1: E402 module level import not at top of file
app/auth/__init__.py:5:1: F401 'app.auth.routes' imported but unused
app/auth/__init__.py:5:1: E402 module level import not at top of file
app/errors/__init__.py:5:1: F401 'app.errors.handlers' imported but unused
app/errors/__init__.py:5:1: E402 module level import not at top of file
app/main/__init__.py:5:1: F401 'app.main.routes' imported but unused
app/main/__init__.py:5:1: E402 module level import not at top of file
app/models.py:218:57: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
app/models.py:223:57: E712 comparison to False should be 'if cond is False:' or 'if not cond:'

miguelgrinberg avatar Nov 16 '24 15:11 miguelgrinberg

FWIW, I tend to install flake8 along with pylint ... and then use pathogen and syntastic to load in-editor linters for Python files while I use vim. The challenge, there, will come for filetypes, depending on how you load each.

Note: With Flask code, you'll likely see a lot of "circular errors" and the like, due to things like from app import app (as @miguelgrinberg nicely points out in his tutorial).

Overall, you're likely better off using something like pycharm to do a lot of this for you, if you like nicer looking IDEs.

russellvt avatar Jul 23 '25 07:07 russellvt