Skip to content

Commit

Permalink
Remove black, pyupgrade, flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
flodolo committed May 31, 2024
1 parent 38fd972 commit 681e6c4
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 163 deletions.
15 changes: 0 additions & 15 deletions .flake8

This file was deleted.

46 changes: 3 additions & 43 deletions .github/workflows/py-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,6 @@ on:
workflow_dispatch:

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Dependencies
run: |
pip install -U pip
pip install -r requirements/lint.txt
- name: flake8
run: flake8 pontoon

black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Dependencies
run: |
pip install -U pip
pip install -r requirements/lint.txt
- name: black
run: black --check pontoon

pyupgrade:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Dependencies
run: |
pip install -U pip
pip install -r requirements/lint.txt
- name: pyupgrade
run: pyupgrade --py311-plus *.py `find pontoon -name \*.py`

ruff:
runs-on: ubuntu-latest
steps:
Expand All @@ -71,5 +29,7 @@ jobs:
run: |
pip install -U pip
pip install -r requirements/lint.txt
- name: ruff
- name: ruff lint
run: ruff check pontoon
- name: ruff format
run: ruff format --check pontoon
29 changes: 9 additions & 20 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,33 +115,22 @@ To run the required linters on the Python and the Javascript code at once you ca
Python code conventions
=======================

Our Python code is automatically formatted using `black <https://black.readthedocs.io/en/stable/>`_.
Our Python code is automatically formatted using `ruff <https://docs.astral.sh/ruff/>`_.
We enforce that in our Continuous Integration, so you will need to run
black on your code before sending it for review.
ruff on your code before sending it for review.

You can run black locally either as an
`add-on in your code editor <https://black.readthedocs.io/en/stable/editor_integration.html>`_,
or as a `git pre-hook commit <https://black.readthedocs.io/en/stable/version_control_integration.html>`_.
You can run ruff locally either as an
`add-on in your code editor <https://docs.astral.sh/ruff/integrations/#vs-code-official>`_,
or as a `git pre-hook commit <https://docs.astral.sh/ruff/integrations/#pre-commit>`_.
Alternatively, you can format your code using:

.. code-block:: shell
$ make black
$ make ruff
We also require Python code to use newer syntax of Python. You can upgrade automatically by running:

.. code-block:: shell
$ make pyupgrade
Additionally, we use a linter to verify that imports are correct. You can run it with:

.. code-block:: shell
$ make flake8
In the rare case when you cannot fix a flake8 error, use ``# noqa`` to make the linter
ignore that error. Note that in most cases, it is better to fix the issues than ignoring them.
In the rare case when you cannot fix an error, use ``# noqa`` to make the linter
ignore that error (see `documentation <https://docs.astral.sh/ruff/linter/#error-suppression>`_).
Note that in most cases, it is better to fix the issues than ignoring them.


Javascript code conventions
Expand Down
30 changes: 6 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SITE_URL ?= http://localhost:8000
USER_ID?=1000
GROUP_ID?=1000

.PHONY: build build-translate build-tagadmin build-server server-env setup run clean shell ci test test-translate test-tagadmin test-server jest pytest format lint types eslint prettier check-prettier flake8 pyupgrade check-pyupgrade black check-black ruff check-ruff dropdb dumpdb loaddb sync-projects requirements
.PHONY: build build-translate build-tagadmin build-server server-env setup run clean shell ci test test-translate test-tagadmin test-server jest pytest format lint types eslint prettier check-prettier ruff check-ruff dropdb dumpdb loaddb sync-projects requirements

help:
@echo "Welcome to Pontoon!\n"
Expand All @@ -34,11 +34,6 @@ help:
@echo " eslint Runs a code linter on the JavaScript code"
@echo " prettier Runs the Prettier formatter"
@echo " check-prettier Runs a check for format issues with the Prettier formatter"
@echo " flake8 Runs the flake8 style guides on all Python code"
@echo " pyupgrade Upgrades all Python code to newer syntax of Python"
@echo " check-pyupgrade Runs a check for outdated syntax of Python with the pyupgrade formatter"
@echo " black Runs the black formatter on all Python code"
@echo " check-black Runs a check for format issues with the black formatter"
@echo " dropdb Completely remove the postgres container and its data"
@echo " ruff Runs the ruff formatter on all Python code"
@echo " check-ruff Runs a check for format issues with the ruff formatter"
Expand Down Expand Up @@ -101,9 +96,9 @@ test-server: pytest
pytest:
"${DC}" run ${run_opts} --rm server pytest --cov-report=xml:pontoon/coverage.xml --cov=. $(opts)

format: prettier pyupgrade black ruff
format: prettier ruff

lint: types eslint check-prettier flake8 check-pyupgrade check-black check-ruff
lint: types eslint check-prettier check-ruff

types:
npm run types -w translate
Expand All @@ -117,26 +112,13 @@ prettier:
check-prettier:
npm run check-prettier

flake8:
"${DC}" run --rm server flake8 pontoon/

pyupgrade:
"${DC}" run --rm server pyupgrade --exit-zero-even-if-changed --py311-plus *.py `find pontoon -name \*.py`

check-pyupgrade:
"${DC}" run --rm server pyupgrade --py311-plus *.py `find pontoon -name \*.py`

black:
"${DC}" run --rm server black pontoon/

check-black:
"${DC}" run --rm server black --check pontoon

ruff:
"${DC}" run --rm server ruff --fix pontoon/
"${DC}" run --rm server ruff check --fix pontoon/
"${DC}" run --rm server ruff format pontoon/

check-ruff:
"${DC}" run --rm server ruff check pontoon
"${DC}" run --rm server ruff format --check pontoon

dropdb:
"${DC}" down --volumes postgresql
Expand Down
3 changes: 0 additions & 3 deletions requirements/lint.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
# The dependencies are sorted by alphabetical order.
# Dependencies that do not come from pypi (eg. eggs from github) are listed at the end of the list.
# -------------------------------------------------------------------------------------------------
black==22.12.0
flake8==3.7.7
pyupgrade==3.15.2
ruff==0.4.6
58 changes: 0 additions & 58 deletions requirements/lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,6 @@
#
# ./docker/compile_requirements.sh
#
black==22.12.0 \
--hash=sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320 \
--hash=sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351 \
--hash=sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350 \
--hash=sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f \
--hash=sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf \
--hash=sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148 \
--hash=sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4 \
--hash=sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d \
--hash=sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc \
--hash=sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d \
--hash=sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2 \
--hash=sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f
# via -r requirements/lint.in
click==8.1.7 \
--hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28 \
--hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de
# via black
entrypoints==0.3 \
--hash=sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19 \
--hash=sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451
# via flake8
flake8==3.7.7 \
--hash=sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661 \
--hash=sha256:a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8
# via -r requirements/lint.in
mccabe==0.6.1 \
--hash=sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42 \
--hash=sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f
# via flake8
mypy-extensions==1.0.0 \
--hash=sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d \
--hash=sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782
# via black
pathspec==0.12.1 \
--hash=sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08 \
--hash=sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712
# via black
platformdirs==4.2.0 \
--hash=sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068 \
--hash=sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768
# via black
pycodestyle==2.5.0 \
--hash=sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56 \
--hash=sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c
# via flake8
pyflakes==2.1.1 \
--hash=sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0 \
--hash=sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2
# via flake8
pyupgrade==3.15.2 \
--hash=sha256:c488d6896c546d25845712ef6402657123008d56c1063174e27aabe15bd6b4e5 \
--hash=sha256:ce309e0ff8ecb73f56a45f12570be84bbbde9540d13697cacb261a7f595fb1f5
# via -r requirements/lint.in
ruff==0.4.6 \
--hash=sha256:04a80acfc862e0e1630c8b738e70dcca03f350bad9e106968a8108379e12b31f \
--hash=sha256:0cf5cc02d3ae52dfb0c8a946eb7a1d6ffe4d91846ffc8ce388baa8f627e3bd50 \
Expand All @@ -77,7 +23,3 @@ ruff==0.4.6 \
--hash=sha256:ef995583a038cd4a7edf1422c9e19118e2511b8ba0b015861b4abd26ec5367c5 \
--hash=sha256:f13410aabd3b5776f9c5699f42b37a3a348d65498c4310589bc6e5c548dc8a2f
# via -r requirements/lint.in
tokenize-rt==5.2.0 \
--hash=sha256:9fe80f8a5c1edad2d3ede0f37481cc0cc1538a2f442c9c2f9e4feacd2792d054 \
--hash=sha256:b79d41a65cfec71285433511b50271b05da3584a1da144a0752e9c621a285289
# via pyupgrade
24 changes: 24 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
line-length = 88
indent-width = 4

# Assume Python 3.11
target-version = "py311"

[lint]
ignore = [
"E501", # Line too long
]
select = [
"E", # pycodestyle errors
"F", # pyflakes
"W", # pycodestyle warnings
]

[format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "lf"

docstring-code-format = false
docstring-code-line-length = "dynamic"

0 comments on commit 681e6c4

Please sign in to comment.