Repository: ClearcodeHQ/pytest-elasticsearch (language: python)

Issue:
Replace pycodestyle/pydocstyle (pylint?) with ruff



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml
index 8c1ce9e2..af6d6aac 100644
--- a/.github/workflows/linters.yml
+++ b/.github/workflows/linters.yml
@@ -11,6 +11,5 @@ jobs:
     uses: fizyk/actions-reuse/.github/workflows/linters-python.yml@v2.1.2
     with:
       pipenv-install-options: "--skip-lock"
-      pydocstyle: true
-      pycodestyle: true
+      ruff: true
       black: true
diff --git a/Pipfile b/Pipfile
index 175afd27..ece418ce 100644
--- a/Pipfile
+++ b/Pipfile
@@ -11,9 +11,8 @@ elasticsearch = "==7.17.0"
 
 [dev-packages]
 towncrier = "==23.6.0"
-pycodestyle = "==2.10.0"
-pydocstyle = "==6.3.0"
 black = "==23.3.0"
 pytest-xdist = "==3.3.1"
 pytest-cov = "==4.1.0"
 mock = "==5.0.2"
+ruff = "==0.0.272"
diff --git a/Pipfile.lock b/Pipfile.lock
index ad70c77a..5a8c836e 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "ffac52a1fdc857b559628b084c5cc05e8c4154627dc4166790d9ba2526009392"
+            "sha256": "fa90ace3f6b5b886b8322b8420da2faf771e064176d436a9cd68e317a8fc3f11"
         },
         "pipfile-spec": 6,
         "requires": {},
@@ -357,22 +357,6 @@
             "markers": "python_version >= '3.7'",
             "version": "==1.1.0"
         },
-        "pycodestyle": {
-            "hashes": [
-                "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053",
-                "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610"
-            ],
-            "index": "pypi",
-            "version": "==2.10.0"
-        },
-        "pydocstyle": {
-            "hashes": [
-                "sha256:118762d452a49d6b05e194ef344a55822987a462831ade91ec5c06fd2169d019",
-                "sha256:7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1"
-            ],
-            "index": "pypi",
-            "version": "==6.3.0"
-        },
         "pytest": {
             "hashes": [
                 "sha256:cdcbd012c9312258922f8cd3f1b62a6580fdced17db6014896053d47cddf9295",
@@ -397,12 +381,28 @@
             "index": "pypi",
             "version": "==3.3.1"
         },
-        "snowballstemmer": {
-            "hashes": [
-                "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1",
-                "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"
+        "ruff": {
+            "hashes": [
+                "sha256:06b8ee4eb8711ab119db51028dd9f5384b44728c23586424fd6e241a5b9c4a3b",
+                "sha256:1609b864a8d7ee75a8c07578bdea0a7db75a144404e75ef3162e0042bfdc100d",
+                "sha256:19643d448f76b1eb8a764719072e9c885968971bfba872e14e7257e08bc2f2b7",
+                "sha256:273a01dc8c3c4fd4c2af7ea7a67c8d39bb09bce466e640dd170034da75d14cab",
+                "sha256:27b2ea68d2aa69fff1b20b67636b1e3e22a6a39e476c880da1282c3e4bf6ee5a",
+                "sha256:48eccf225615e106341a641f826b15224b8a4240b84269ead62f0afd6d7e2d95",
+                "sha256:677284430ac539bb23421a2b431b4ebc588097ef3ef918d0e0a8d8ed31fea216",
+                "sha256:691d72a00a99707a4e0b2846690961157aef7b17b6b884f6b4420a9f25cd39b5",
+                "sha256:86bc788245361a8148ff98667da938a01e1606b28a45e50ac977b09d3ad2c538",
+                "sha256:905ff8f3d6206ad56fcd70674453527b9011c8b0dc73ead27618426feff6908e",
+                "sha256:9c4bfb75456a8e1efe14c52fcefb89cfb8f2a0d31ed8d804b82c6cf2dc29c42c",
+                "sha256:a37ec80e238ead2969b746d7d1b6b0d31aa799498e9ba4281ab505b93e1f4b28",
+                "sha256:ae9b57546e118660175d45d264b87e9b4c19405c75b587b6e4d21e6a17bf4fdf",
+                "sha256:bd2bbe337a3f84958f796c77820d55ac2db1e6753f39d1d1baed44e07f13f96d",
+                "sha256:d5a208f8ef0e51d4746930589f54f9f92f84bb69a7d15b1de34ce80a7681bc00",
+                "sha256:dc406e5d756d932da95f3af082814d2467943631a587339ee65e5a4f4fbe83eb",
+                "sha256:ee76b4f05fcfff37bd6ac209d1370520d509ea70b5a637bdf0a04d0c99e13dff"
             ],
-            "version": "==2.2.0"
+            "index": "pypi",
+            "version": "==0.0.272"
         },
         "towncrier": {
             "hashes": [
diff --git a/newsfragments/472.misc.rst b/newsfragments/472.misc.rst
new file mode 100644
index 00000000..1c2f4069
--- /dev/null
+++ b/newsfragments/472.misc.rst
@@ -0,0 +1,1 @@
+Replace pycodestyle and pydocstyle with ruff
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 9f3866c5..01c2ee25 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -7,6 +7,16 @@ line-length = 100
 target-version = ['py38']
 include = '.*\.pyi?$'
 
+[tool.ruff]
+# Decrease the maximum line length to 79 characters.
+line-length = 100
+select = [
+    "E",   # pycodestyle
+    "F",   # pyflakes
+    "I",   # isort
+    "D",   # pydocstyle
+]
+
 [tool.towncrier]
 directory = "newsfragments"
 single_file=true
diff --git a/setup.cfg b/setup.cfg
index ec53b5df..7f51d056 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -47,14 +47,6 @@ tests =
     pytest-xdist
     mock
 
-[pycodestyle]
-max-line-length = 100
-exclude = docs/*,build/*,venv/*
-
-[pydocstyle]
-ignore = D203,D212
-match = '(?!docs|build|venv).*\.py'
-
 [tool:pytest]
 addopts = --max-worker-restart=0 --showlocals --verbose  --cov src/pytest_elasticsearch  --cov tests
 testpaths = tests


Test patch:
diff --git a/pytest_elasticsearch/executor.py b/pytest_elasticsearch/executor.py
index c6042ca9..349f27c7 100644
--- a/pytest_elasticsearch/executor.py
+++ b/pytest_elasticsearch/executor.py
@@ -11,10 +11,10 @@ class NoopElasticsearch:  # pylint:disable=too-few-public-methods
     """No operation Elasticsearch executor mock."""
 
     def __init__(self, host, port):
-        """
-        Initialize Elasticsearch executor mock
+        """Initialize Elasticsearch executor mock.
+
         :param str host: hostname under which elasticsearch is available
-        :param int port: port under which elasticsearch is available
+        :param int port: port under which elasticsearch is available.
         """
         self.host = host
         self.port = port
@@ -43,8 +43,7 @@ def __init__(
         index_store_type,
         timeout,
     ):  # pylint:disable=too-many-arguments
-        """
-        Initialize ElasticSearchExecutor.
+        """Initialize ElasticSearchExecutor.
 
         :param pathlib.Path executable: Executable path
         :param str host: hostname under which elasticsearch will be running
@@ -79,8 +78,7 @@ def __init__(
 
     @property
     def version(self):
-        """
-        Get the given elasticsearch executable version parts.
+        """Get the given elasticsearch executable version parts.
 
         :return: Elasticsearch version
         :rtype: pkg_resources.Version
@@ -106,8 +104,7 @@ def version(self):
         return self._version
 
     def _exec_command(self):
-        """
-        Get command to run elasticsearch binary based on the version.
+        """Get command to run elasticsearch binary based on the version.
 
         :return: command to run elasticsearch
         :rtype: str
diff --git a/pytest_elasticsearch/factories.py b/pytest_elasticsearch/factories.py
index 8c6fca96..bf7b9b81 100644
--- a/pytest_elasticsearch/factories.py
+++ b/pytest_elasticsearch/factories.py
@@ -19,10 +19,10 @@
 import shutil
 
 import pytest
-from pytest import FixtureRequest, TempPathFactory
 from elasticsearch import Elasticsearch
 from mirakuru import ProcessExitedWithError
 from port_for import get_port
+from pytest import FixtureRequest, TempPathFactory
 
 from pytest_elasticsearch.executor import ElasticSearchExecutor, NoopElasticsearch
 
@@ -55,8 +55,7 @@ def elasticsearch_proc(
     network_publish_host=None,
     index_store_type=None,
 ):
-    """
-    Create elasticsearch process fixture.
+    """Create elasticsearch process fixture.
 
     .. warning::
 
@@ -131,8 +130,7 @@ def elasticsearch_proc_fixture(
 
 
 def elasticsearch_noproc(host=None, port=None):
-    """
-    Elasticsearch noprocess factory.
+    """Elasticsearch noprocess factory.
 
     :param str host: hostname
     :param str|int port: exact port (e.g. '8000', 8000)
@@ -142,8 +140,7 @@ def elasticsearch_noproc(host=None, port=None):
 
     @pytest.fixture(scope="session")
     def elasticsearch_noproc_fixture(request):
-        """
-        Noop Process fixture for PostgreSQL.
+        """Noop Process fixture for PostgreSQL.
 
         :param FixtureRequest request: fixture request object
         :rtype: pytest_dbfixtures.executors.TCPExecutor
@@ -161,8 +158,7 @@ def elasticsearch_noproc_fixture(request):
 
 
 def elasticsearch(process_fixture_name):
-    """
-    Create Elasticsearch client fixture.
+    """Create Elasticsearch client fixture.
 
     :param str process_fixture_name: elasticsearch process fixture name
     """
diff --git a/pytest_elasticsearch/plugin.py b/pytest_elasticsearch/plugin.py
index 3384ee82..761cb26b 100644
--- a/pytest_elasticsearch/plugin.py
+++ b/pytest_elasticsearch/plugin.py
@@ -33,7 +33,6 @@
 
 def pytest_addoption(parser):
     """Add plugin's configuration options."""
-
     parser.addini(name="elasticsearch_host", help=_help_host, default="127.0.0.1")
 
     parser.addini(
diff --git a/tests/conftest.py b/tests/conftest.py
index 2f0c3728..51f994a3 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,8 +1,8 @@
 """Tests main conftest file."""
 import warnings
 
-from pytest_elasticsearch.plugin import *
 from pytest_elasticsearch import factories
+from pytest_elasticsearch.plugin import *  # noqa: F403
 
 warnings.simplefilter("error", category=DeprecationWarning)
 
diff --git a/tests/test_elastic.py b/tests/test_elastic.py
index 3d7cd018..3ac15bf3 100644
--- a/tests/test_elastic.py
+++ b/tests/test_elastic.py
@@ -1,6 +1,5 @@
 """Pytest-elasticsearch tests."""
 from datetime import datetime
-from tempfile import gettempdir
 
 import mock
 import pytest
@@ -9,7 +8,6 @@
 from pytest_elasticsearch import factories
 from pytest_elasticsearch.executor import ElasticSearchExecutor
 
-
 VERSION_STRING_6_8 = (
     "OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was "
     "deprecated in version 9.0 and will likely be removed in a future release."