fix(ci): Replace flake8 with ruff

This commit is contained in:
Serhii Tereshchenko 2023-10-15 15:41:49 +03:00
parent 7474599c3d
commit 2061f6c264
5 changed files with 43 additions and 68 deletions

View file

@ -25,10 +25,10 @@ jobs:
- name: Install linters
run: |
python -m pip install --upgrade pip
pip install flake8 black
pip install ruff==0.0.292 black==23.9.1
- name: Run linters
run: |
flake8 modeltranslation
ruff check modeltranslation
black --check modeltranslation *.py
- name: Test package install
run: |

View file

@ -23,7 +23,7 @@ def autodiscover():
before_import_registry = copy.copy(translator._registry)
try:
import_module(module)
except:
except ImportError:
# Reset the model registry to the state before the last import as
# this import will have to reoccur on the next request and this
# could raise NotRegistered and AlreadyRegistered exceptions

View file

@ -278,12 +278,9 @@ class ModeltranslationTest(ModeltranslationTestBase):
def test_descriptor_introspection(self):
# See Django #8248
try:
models.TestModel.title
models.TestModel.title.__doc__
assert True
except:
self.fail('Descriptor accessed on class should return itself.')
assert isinstance(
models.TestModel.title.__doc__, str
), 'Descriptor accessed on class should return itself.'
def test_fields_hashes(self):
opts = models.TestModel._meta
@ -2212,9 +2209,9 @@ class ModelInheritanceTest(ModeltranslationTestBase):
assert 'titleb' in field_names_b
assert 'titleb_de' in field_names_b
assert 'titleb_en' in field_names_b
assert not ('titled' in field_names_b)
assert not ('titled_de' in field_names_b)
assert not ('titled_en' in field_names_b)
assert 'titled' not in field_names_b
assert 'titled_de' not in field_names_b
assert 'titled_en' not in field_names_b
def test_multitable_inheritance(self):
field_names_a = get_field_names(models.MultitableModelA)

77
poetry.lock generated
View file

@ -262,22 +262,6 @@ files = [
pyreadline = {version = "*", markers = "platform_system == \"Windows\""}
pyrepl = ">=0.8.2"
[[package]]
name = "flake8"
version = "5.0.4"
description = "the modular source code checker: pep8 pyflakes and co"
optional = false
python-versions = ">=3.6.1"
files = [
{file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"},
{file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"},
]
[package.dependencies]
mccabe = ">=0.7.0,<0.8.0"
pycodestyle = ">=2.9.0,<2.10.0"
pyflakes = ">=2.5.0,<2.6.0"
[[package]]
name = "iniconfig"
version = "2.0.0"
@ -289,17 +273,6 @@ files = [
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
]
[[package]]
name = "mccabe"
version = "0.7.0"
description = "McCabe checker, plugin for flake8"
optional = false
python-versions = ">=3.6"
files = [
{file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"},
{file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
]
[[package]]
name = "mypy-extensions"
version = "1.0.0"
@ -397,28 +370,6 @@ files = [
dev = ["pre-commit", "tox"]
testing = ["pytest", "pytest-benchmark"]
[[package]]
name = "pycodestyle"
version = "2.9.1"
description = "Python style guide checker"
optional = false
python-versions = ">=3.6"
files = [
{file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"},
{file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"},
]
[[package]]
name = "pyflakes"
version = "2.5.0"
description = "passive checker of Python programs"
optional = false
python-versions = ">=3.6"
files = [
{file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"},
{file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"},
]
[[package]]
name = "pygments"
version = "2.16.1"
@ -530,6 +481,32 @@ termcolor = ">=2.1.0"
[package.extras]
dev = ["black", "flake8", "pre-commit"]
[[package]]
name = "ruff"
version = "0.0.292"
description = "An extremely fast Python linter, written in Rust."
optional = false
python-versions = ">=3.7"
files = [
{file = "ruff-0.0.292-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:02f29db018c9d474270c704e6c6b13b18ed0ecac82761e4fcf0faa3728430c96"},
{file = "ruff-0.0.292-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:69654e564342f507edfa09ee6897883ca76e331d4bbc3676d8a8403838e9fade"},
{file = "ruff-0.0.292-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c3c91859a9b845c33778f11902e7b26440d64b9d5110edd4e4fa1726c41e0a4"},
{file = "ruff-0.0.292-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f4476f1243af2d8c29da5f235c13dca52177117935e1f9393f9d90f9833f69e4"},
{file = "ruff-0.0.292-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:be8eb50eaf8648070b8e58ece8e69c9322d34afe367eec4210fdee9a555e4ca7"},
{file = "ruff-0.0.292-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:9889bac18a0c07018aac75ef6c1e6511d8411724d67cb879103b01758e110a81"},
{file = "ruff-0.0.292-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6bdfabd4334684a4418b99b3118793f2c13bb67bf1540a769d7816410402a205"},
{file = "ruff-0.0.292-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:aa7c77c53bfcd75dbcd4d1f42d6cabf2485d2e1ee0678da850f08e1ab13081a8"},
{file = "ruff-0.0.292-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8e087b24d0d849c5c81516ec740bf4fd48bf363cfb104545464e0fca749b6af9"},
{file = "ruff-0.0.292-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f160b5ec26be32362d0774964e218f3fcf0a7da299f7e220ef45ae9e3e67101a"},
{file = "ruff-0.0.292-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:ac153eee6dd4444501c4bb92bff866491d4bfb01ce26dd2fff7ca472c8df9ad0"},
{file = "ruff-0.0.292-py3-none-musllinux_1_2_i686.whl", hash = "sha256:87616771e72820800b8faea82edd858324b29bb99a920d6aa3d3949dd3f88fb0"},
{file = "ruff-0.0.292-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:b76deb3bdbea2ef97db286cf953488745dd6424c122d275f05836c53f62d4016"},
{file = "ruff-0.0.292-py3-none-win32.whl", hash = "sha256:e854b05408f7a8033a027e4b1c7f9889563dd2aca545d13d06711e5c39c3d003"},
{file = "ruff-0.0.292-py3-none-win_amd64.whl", hash = "sha256:f27282bedfd04d4c3492e5c3398360c9d86a295be00eccc63914438b4ac8a83c"},
{file = "ruff-0.0.292-py3-none-win_arm64.whl", hash = "sha256:7f67a69c8f12fbc8daf6ae6d36705037bde315abf8b82b6e1f4c9e74eb750f68"},
{file = "ruff-0.0.292.tar.gz", hash = "sha256:1093449e37dd1e9b813798f6ad70932b57cf614e5c2b5c51005bf67d55db33ac"},
]
[[package]]
name = "sqlparse"
version = "0.4.4"
@ -613,4 +590,4 @@ test = ["pytest"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.8,<4"
content-hash = "d2e4285619e0aba71a2bf5adad18d77d2340e4d9b4e8eb5c13bfdc94cb6aaa8b"
content-hash = "e4e750b7f8f0ed6588adf2b759782c27fede993ba32e47785c0c23a3f08c8d91"

View file

@ -11,10 +11,10 @@ packages = [
[tool.poetry.dependencies]
python = ">=3.8,<4"
django = ">=3.2"
ruff = "^0.0.292"
[tool.poetry.dev-dependencies]
pdbpp = "*"
flake8 = "*"
black = "*"
parameterized = "*"
pytest-cov = "*"
@ -27,8 +27,9 @@ django-types = "*"
line-length = 100
skip-string-normalization = true
[tool.isort]
line_length = 100
multi_line_output = 3
skip_gitignore = true
include_trailing_comma = true
[tool.ruff]
line-length = 100
target-version = "py38"
ignore = [
"E501", # line length is handled by black
]