diff --git a/Makefile-docker b/Makefile-docker index cfc17ca88f..f5360309a1 100644 --- a/Makefile-docker +++ b/Makefile-docker @@ -169,7 +169,7 @@ perf-tests: setup-ui-tests .PHONY: lint lint: ## lint the code black --check src/ tests/ - flake8 src/ tests/ + ruff check . NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- prettier --check '**' curlylint src/ @@ -235,6 +235,7 @@ watch_js_tests: ## Run+watch the JavaScript test suite (requires compiled/compre .PHONY: format format: ## Autoformat our codebase. NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- prettier --write '**' + ruff check --fix-only . black src/ tests/ .PHONY: help_submake diff --git a/locale/generate_category_po_files.py b/locale/generate_category_po_files.py index d9023de720..7d62e0b915 100755 --- a/locale/generate_category_po_files.py +++ b/locale/generate_category_po_files.py @@ -76,7 +76,7 @@ def main(): print('Skipping locale %s, it has no translations :(' % locale) continue - print("Writing %d translations to %s" % ( + print('Writing %d translations to %s' % ( len(translations_for_this_locale), fname)) write_po(fname, translations_for_this_locale) diff --git a/manage.py b/manage.py index 9fe20678fe..a1e025e6c2 100755 --- a/manage.py +++ b/manage.py @@ -3,7 +3,7 @@ import sys import os -if __name__ == "__main__": +if __name__ == '__main__': os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') from django.core.management import execute_from_command_line diff --git a/pyproject.toml b/pyproject.toml index ef49b4aad4..e1b5005155 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,26 +2,38 @@ line-length = 88 target-version = ['py310'] skip-string-normalization = true -exclude = ''' +extend-exclude = ''' ( /( docs - | node_modules - | build*.py - | media - | storage - | logs - | site-static | static | \.git - | \.npm )/ | src/.*/migrations/.*\.py | src/olympia/translations/tests/testapp/migrations/.*\.py - | src/django-babel/.*\.py ) ''' +[tool.ruff] +exclude = [ + "docs", + "static", + ".git", + "*/migrations/*.py", +] +ignore = ["F405", "B004", "B007", "B009", "B010", "B015", "B017", "B018", "B023", "B026", "B028", "B904", "B905"] +line-length = 88 +select = [ + "B", + "E", + "F", + "Q", + "W", +] + +[tool.ruff.flake8-quotes] +inline-quotes = "single" + [tool.pytest.ini_options] addopts = "-vs --reuse-db --showlocals --tb=short" python_files = "test*.py" diff --git a/requirements/codestyle.txt b/requirements/codestyle.txt index 07b6e2c008..5e60aea3fb 100644 --- a/requirements/codestyle.txt +++ b/requirements/codestyle.txt @@ -1,24 +1,5 @@ -r system.txt -# flake8 is required by flake8-mutable -flake8==6.0.0 \ - --hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \ - --hash=sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181 -flake8-mutable==1.2.0 \ - --hash=sha256:ee9b77111b867d845177bbc289d87d541445ffcc6029a0c5c65865b42b18c6a6 \ - --hash=sha256:38fd9dadcbcda6550a916197bc40ed76908119dabb37fbcca30873666c31d2d5 -# mccabe is required by flake8 -mccabe==0.7.0 \ - --hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e \ - --hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 -# pycodestyle is required by flake8 -pycodestyle==2.10.0 \ - --hash=sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053 \ - --hash=sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610 -# pyflakes is required by flake8 -pyflakes==3.0.1 \ - --hash=sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf \ - --hash=sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd # attrs is required by curlylint attrs==23.1.0 \ --hash=sha256:1f28b4522cdc2fb4256ac1a020c78acf9cba2c6b461ccd2c126f3aa8e8335d04 \ @@ -70,9 +51,24 @@ mypy-extensions==1.0.0 \ platformdirs==3.5.0 \ --hash=sha256:47692bc24c1958e8b0f13dd727307cff1db103fca36399f457da8e05f222fdc4 \ --hash=sha256:7954a68d0ba23558d753f73437c55f89027cf8f5108c19844d4b82e5af396335 -flake8-quotes==3.3.2 \ - --hash=sha256:6e26892b632dacba517bf27219c459a8396dcfac0f5e8204904c5a4ba9b480e1 tomli==2.0.1 \ --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f - +ruff==0.0.264 \ + --hash=sha256:04ec5d75e4bca754cedd20d53e2ba4920d6259e7579abfb2e8e30c3c80e41b17 \ + --hash=sha256:05ee163a046fc593d150179d23f4af447fb82f3e59cd34e031ea0868c65bb8e8 \ + --hash=sha256:068a82a29d80848a56e3d9d4308e6e0ca8b2ecdaf5ac342a292545a59b7f2c21 \ + --hash=sha256:18a29ed37bf8cfe6dce8a2db56c313a64c0804095108753621f3c3321e0c9c5f \ + --hash=sha256:323ae6c1702b26c96d0fbf939c5959c37e79021f86b70f63634df918bc77f36e \ + --hash=sha256:3e2c38449548e122f2612843a7c04e22b4fd491656955c57b8cb05df11639ad6 \ + --hash=sha256:4564e0f245eb515c6ed63988c21e9c40bcfd485cd1ec63bdd790f9a81d301f15 \ + --hash=sha256:484e395d1984ab9e1e66bd42e7a5192decfee86998d07d36ee50b2fadccc8734 \ + --hash=sha256:5a8658ebcc37d62f72840cbdf564171c1a2b6831db482b4d917962541a2f4a44 \ + --hash=sha256:67326fdc9ac0a1b13e229c6e24e8d115863c52cd710faaaaa588851535281d6c \ + --hash=sha256:71fd865ebacc1083259b3fb7e3eb45235a86e62e21830b8a6b067be0ec54aa2e \ + --hash=sha256:8fcd4b693ca1374eb7a5796581c90689f884f98f388740d94f0702fd30f8f78f \ + --hash=sha256:91c6eb4f979b661a2dd850d9ac803842bb7b66d4926de84f09c787af82590f73 \ + --hash=sha256:cd4f60ffc3eb15802c554a9c8581bf2117c4d3d06fbc57e0ba58f04cb1aaa47f \ + --hash=sha256:d628de91e2be7a83128526636097d2dd890669a06143f826f6c591d79aeefbc4 \ + --hash=sha256:d97ba8db0fb601ffe9ee996ebb97c698e427a2fd4514fefbe7b803111354f783 \ + --hash=sha256:ec2fa192c035b8b68cc2b91049c561cd69543e2b8c4d157d9aa7727320bedcca diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 8c720e6970..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,19 +0,0 @@ -[flake8] -# E203: https://github.com/psf/black/issues/315 -# W503: https://www.flake8rules.com/rules/W503.html -ignore = F999,F405,W503,E203 -max-line-length = 88 -exclude = - src/olympia/wsgi.py, - docs, - node_modules, - .npm, - build*.py - media, - storage, - logs, - site-static, - static, - .git, - */migrations/*.py - src/django-babel/ diff --git a/src/olympia/addons/tests/test_views.py b/src/olympia/addons/tests/test_views.py index 54cbe0f2fd..6e8b480309 100644 --- a/src/olympia/addons/tests/test_views.py +++ b/src/olympia/addons/tests/test_views.py @@ -5598,7 +5598,9 @@ class TestAddonSearchView(ESTestCase): for i in range(0, 10): addon_factory() self.refresh() - query = '남포역립카페추천 ˇjjtat닷컴ˇ ≡제이제이♠♣ 남포역스파 남포역op남포역유흥≡남포역안마남포역오피 ♠♣' + query = ( + '남포역립카페추천 ˇjjtat닷컴ˇ ≡제이제이♠♣ 남포역스파 남포역op남포역유흥≡남포역안마남포역오피 ♠♣' # noqa: E501 + ) data = self.perform_search(self.url, {'q': query}) # No results, but no 500 either. assert data['count'] == 0 diff --git a/src/olympia/lib/crypto/tasks.py b/src/olympia/lib/crypto/tasks.py index 0008562b3b..91b52b0dd7 100644 --- a/src/olympia/lib/crypto/tasks.py +++ b/src/olympia/lib/crypto/tasks.py @@ -42,7 +42,7 @@ Regards, The Add-ons Team --- -[1] https://extensionworkshop.com/documentation/publish/signing-and-distribution-overview/ # noqa +[1] https://extensionworkshop.com/documentation/publish/signing-and-distribution-overview/ [2] https://wiki.mozilla.org/Release_Management/Calendar [3] https://www.mozilla.org/firefox/enterprise/ -- @@ -50,7 +50,7 @@ The Add-ons Team You have received this email because you are a registered developer of a Firefox add-on. If you do not want to receive these updates regarding your add-on, please sign in to addons.mozilla.org and delete your add-on(s). -""" +""" # noqa: E501 version_regex = re.compile( r'^(?P.*)(?P\.1\-signed)(|\-(?P\d+))$' diff --git a/src/olympia/reviewers/tests/test_views.py b/src/olympia/reviewers/tests/test_views.py index 037f62b48f..7dd5889606 100644 --- a/src/olympia/reviewers/tests/test_views.py +++ b/src/olympia/reviewers/tests/test_views.py @@ -1812,7 +1812,9 @@ class TestThemeNominatedQueue(QueueTest): ) def test_queue_layout(self): - self._test_queue_layout('🎨 New', tab_position=0, total_addons=2, total_queues=2) + self._test_queue_layout( + '🎨 New', tab_position=0, total_addons=2, total_queues=2 + ) # noqa: E501 def test_static_theme_filtered_out(self): self.addons['Nominated Two'].update(type=amo.ADDON_EXTENSION)