pittcsc / PittAPI

An API to easily get data from the University of Pittsburgh
https://pittapi.pittcsc.org
GNU General Public License v2.0
105 stars 30 forks source link

Add black and flake8 #174

Closed tianyizheng02 closed 3 weeks ago

tianyizheng02 commented 1 month ago

See this comment thread in #170 for more details

Add black to pre-commit and GitHub actions for automatic code formatting. Also update black to the latest version, as the old version was breaking due to an ImportError.

Add flake8 to pre-commit and Pipfile dependencies for automatic linting beyond GitHub actions.

tianyizheng02 commented 1 month ago
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt

@nij-patel We're still using pip and requirements.txt in our GitHub Actions workflows when we've already transitioned to using pipenv and Pipfile for our dependencies. Is it OK to update the GitHub workflows to use pipenv as well?

tianyizheng02 commented 1 month ago

black fails as expected, since I haven't yet run black on the codebase. I'll keep the flake8 step of the workflows as is, but I don't think they should just let those 97 warnings pass. We can leave that for possible future work.

tianyizheng02 commented 1 month ago

Codebase passes pre-commit and GitHub Actions workflows with flake8 and black enabled

For future reference, note that flake8 is currently only configured to check for syntax errors and undefined names, which is far too narrow. This will need to be broadened to check for more errors (e.g., unused imports and common antipatterns).

tianyizheng02 commented 3 weeks ago

@RitwikGupta?