From c8e44f56c400e69c95d7f6f623c0d7d5df4be526 Mon Sep 17 00:00:00 2001 From: Serhii Tereshchenko Date: Sat, 25 Nov 2023 13:33:59 +0200 Subject: [PATCH] chore: Switch to ruff format --- .github/workflows/test.yml | 5 +- Makefile | 4 ++ docs/modeltranslation/contribute.rst | 12 ++-- poetry.lock | 101 +-------------------------- pyproject.toml | 7 +- setup.cfg | 4 -- 6 files changed, 14 insertions(+), 119 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52ecb14..6eb6f4b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,11 +25,10 @@ jobs: - name: Install linters run: | python -m pip install --upgrade pip - pip install ruff==0.0.292 black==23.9.1 + pip install ruff==0.1.6 - name: Run linters run: | - ruff check modeltranslation - black --check modeltranslation *.py + make lint - name: Test package install run: | python -m pip install --upgrade pip diff --git a/Makefile b/Makefile index 89dbdeb..27f505d 100644 --- a/Makefile +++ b/Makefile @@ -8,3 +8,7 @@ publish: clean clean: rm -rf dist + +lint: + ruff check modeltranslation + ruff format --check modeltranslation *.py diff --git a/docs/modeltranslation/contribute.rst b/docs/modeltranslation/contribute.rst index fe923ea..03de3bb 100644 --- a/docs/modeltranslation/contribute.rst +++ b/docs/modeltranslation/contribute.rst @@ -26,15 +26,14 @@ Coding Style Please make sure that your code follows the `PEP 8`_ style guide. The only exception we make is to allow a maximum line length of 100. Furthermore -your code has to validate against `pyflakes`_. It is recommended to use -`flake8`_ which combines all the checks, and black for code formatting. +your code has to validate against `ruff`_. It is recommended to use +`ruff`_ which combines all the checks, and `ruff format` for code formatting. .. code-block:: console - $ flake8 modeltranslation - $ black modeltranslation *.py + $ make lint -The ``#NOQA`` mark added by `flake8`_ should be used sparsely. +The ``# noqa`` marks for `ruff`_ should be used sparsely. Django and Python Versions @@ -123,8 +122,7 @@ Please do not use the issue tracker for general questions, we run a dedicated .. _help.github.com: https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user .. _PEP 8: http://www.python.org/dev/peps/pep-0008/ -.. _pyflakes: https://pypi.python.org/pypi/pyflakes -.. _flake8: https://pypi.python.org/pypi/flake8 +.. _ruff: https://pypi.python.org/pypi/ruff .. _Github: https://github.com/deschler/django-modeltranslation .. _Github Actions: https://travis-ci.org/deschler/django-modeltranslation .. _Github Actions Workflows: https://github.com/deschler/django-modeltranslation/blob/master/.github/workflows diff --git a/poetry.lock b/poetry.lock index 4da6e34..1b50543 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. [[package]] name = "asgiref" @@ -63,66 +63,6 @@ files = [ [package.extras] tzdata = ["tzdata"] -[[package]] -name = "black" -version = "23.9.1" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-23.9.1-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:d6bc09188020c9ac2555a498949401ab35bb6bf76d4e0f8ee251694664df6301"}, - {file = "black-23.9.1-cp310-cp310-macosx_10_16_universal2.whl", hash = "sha256:13ef033794029b85dfea8032c9d3b92b42b526f1ff4bf13b2182ce4e917f5100"}, - {file = "black-23.9.1-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:75a2dc41b183d4872d3a500d2b9c9016e67ed95738a3624f4751a0cb4818fe71"}, - {file = "black-23.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13a2e4a93bb8ca74a749b6974925c27219bb3df4d42fc45e948a5d9feb5122b7"}, - {file = "black-23.9.1-cp310-cp310-win_amd64.whl", hash = "sha256:adc3e4442eef57f99b5590b245a328aad19c99552e0bdc7f0b04db6656debd80"}, - {file = "black-23.9.1-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:8431445bf62d2a914b541da7ab3e2b4f3bc052d2ccbf157ebad18ea126efb91f"}, - {file = "black-23.9.1-cp311-cp311-macosx_10_16_universal2.whl", hash = "sha256:8fc1ddcf83f996247505db6b715294eba56ea9372e107fd54963c7553f2b6dfe"}, - {file = "black-23.9.1-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:7d30ec46de88091e4316b17ae58bbbfc12b2de05e069030f6b747dfc649ad186"}, - {file = "black-23.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:031e8c69f3d3b09e1aa471a926a1eeb0b9071f80b17689a655f7885ac9325a6f"}, - {file = "black-23.9.1-cp311-cp311-win_amd64.whl", hash = "sha256:538efb451cd50f43aba394e9ec7ad55a37598faae3348d723b59ea8e91616300"}, - {file = "black-23.9.1-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:638619a559280de0c2aa4d76f504891c9860bb8fa214267358f0a20f27c12948"}, - {file = "black-23.9.1-cp38-cp38-macosx_10_16_universal2.whl", hash = "sha256:a732b82747235e0542c03bf352c126052c0fbc458d8a239a94701175b17d4855"}, - {file = "black-23.9.1-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:cf3a4d00e4cdb6734b64bf23cd4341421e8953615cba6b3670453737a72ec204"}, - {file = "black-23.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cf99f3de8b3273a8317681d8194ea222f10e0133a24a7548c73ce44ea1679377"}, - {file = "black-23.9.1-cp38-cp38-win_amd64.whl", hash = "sha256:14f04c990259576acd093871e7e9b14918eb28f1866f91968ff5524293f9c573"}, - {file = "black-23.9.1-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:c619f063c2d68f19b2d7270f4cf3192cb81c9ec5bc5ba02df91471d0b88c4c5c"}, - {file = "black-23.9.1-cp39-cp39-macosx_10_16_universal2.whl", hash = "sha256:6a3b50e4b93f43b34a9d3ef00d9b6728b4a722c997c99ab09102fd5efdb88325"}, - {file = "black-23.9.1-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:c46767e8df1b7beefb0899c4a95fb43058fa8500b6db144f4ff3ca38eb2f6393"}, - {file = "black-23.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50254ebfa56aa46a9fdd5d651f9637485068a1adf42270148cd101cdf56e0ad9"}, - {file = "black-23.9.1-cp39-cp39-win_amd64.whl", hash = "sha256:403397c033adbc45c2bd41747da1f7fc7eaa44efbee256b53842470d4ac5a70f"}, - {file = "black-23.9.1-py3-none-any.whl", hash = "sha256:6ccd59584cc834b6d127628713e4b6b968e5f79572da66284532525a042549f9"}, - {file = "black-23.9.1.tar.gz", hash = "sha256:24b6b3ff5c6d9ea08a8888f6977eae858e1f340d7260cf56d70a49823236b62d"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - -[[package]] -name = "click" -version = "8.1.7" -description = "Composable command line interface toolkit" -optional = false -python-versions = ">=3.7" -files = [ - {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, - {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, -] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - [[package]] name = "colorama" version = "0.4.6" @@ -273,17 +213,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - [[package]] name = "packaging" version = "23.2" @@ -309,17 +238,6 @@ files = [ [package.extras] dev = ["jinja2"] -[[package]] -name = "pathspec" -version = "0.11.2" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.7" -files = [ - {file = "pathspec-0.11.2-py3-none-any.whl", hash = "sha256:1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20"}, - {file = "pathspec-0.11.2.tar.gz", hash = "sha256:e0d8d0ac2f12da61956eb2306b69f9469b42f4deb0f3cb6ed47b9cce9996ced3"}, -] - [[package]] name = "pdbpp" version = "0.10.3" @@ -340,21 +258,6 @@ wmctrl = "*" funcsigs = ["funcsigs"] testing = ["funcsigs", "pytest"] -[[package]] -name = "platformdirs" -version = "3.11.0" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false -python-versions = ">=3.7" -files = [ - {file = "platformdirs-3.11.0-py3-none-any.whl", hash = "sha256:e9d171d00af68be50e9202731309c4e658fd8bc76f55c11c7dd760d023bda68e"}, - {file = "platformdirs-3.11.0.tar.gz", hash = "sha256:cf8ee52a3afdb965072dcc652433e0c7e3e40cf5ea1477cd4b3b1d2eb75495b3"}, -] - -[package.extras] -docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"] - [[package]] name = "pluggy" version = "1.3.0" @@ -590,4 +493,4 @@ test = ["pytest"] [metadata] lock-version = "2.0" python-versions = ">=3.8,<4" -content-hash = "e4e750b7f8f0ed6588adf2b759782c27fede993ba32e47785c0c23a3f08c8d91" +content-hash = "674b72f43b47fa4d738a1236bc45d6a5124f17e351fd2a218aa1e7d430cf78b7" diff --git a/pyproject.toml b/pyproject.toml index e1a29ec..241e8fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ ruff = "^0.0.292" [tool.poetry.dev-dependencies] pdbpp = "*" -black = "*" parameterized = "*" pytest-cov = "*" pytest = "*" @@ -23,13 +22,9 @@ pytest-sugar = "*" pytest-django = "*" django-types = "*" -[tool.black] -line-length = 100 -skip-string-normalization = true - [tool.ruff] line-length = 100 target-version = "py38" ignore = [ - "E501", # line length is handled by black + "E501", # line length is handled by formatter ] diff --git a/setup.cfg b/setup.cfg index 98835a1..533f0d2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,3 @@ packages = modeltranslation = static/modeltranslation/css/*.css static/modeltranslation/js/*.js -[flake8] -max-line-length = 100 -ignore = E722, E241, E203, E266, E501, W503 -exclude = .tox