Repository: gammasim/simtools (language: python)

Issue:
Linter cleanup
There is unnecessary duplication in the linters as implemented in the workflows (positive: better to test twice than not at all). This is amplfied by the recent introduction of added pre-commit runs over all files as CI and the introduction of ruff (not yet added to pre-commit, but planned).

This is the suggestion:

1. Review pre-commit and make sure that any workflows which run reasonable fast are included. 
2. Remove duplications (e.g., flake8 is running in the pre-commits, in CI-linter and CI-unittests! Additionally, ruff is almost 100% compatible with flake8 tests)
3. Replace pylint by ruff in pre-commit. Continue to run pylint in CI-linter
4. Review if we need the super-linter workflow in CI-linter. Given that most linters run using the pre-commit workflows, it might be better to run the few which are not explicitly.
5. If possible, configure tools in pyproject.toml (some tools recently introduced this; e.g., markdownlint)




Discussion / hints:

Fix patch:
diff --git a/.github/workflows/CI-linter.yml b/.github/workflows/CI-linter.yml
index 74ef379c9..290364794 100644
--- a/.github/workflows/CI-linter.yml
+++ b/.github/workflows/CI-linter.yml
@@ -47,34 +47,17 @@ jobs:
 
       - name: install packages not included in super-linter
         run: |
-          pip install validate-pyproject restructuredtext-lint
+          pip install validate-pyproject
 
       - name: pyproject.toml
         run: |
           validate-pyproject pyproject.toml
 
-      # RST linter
-      # Note: unclear how to suppress error messages
-      # (use grep -v in this case)
-    #  - name: restructuredtext-lint
-    #    run: |
-    #      rst-lint README.rst docs/source |
-    #       grep -v "Unknown directive type" |
-    #       grep -v "Unknown interpreted text role" |
-    #       grep -v "Cannot analyze code. Pygments package not found."
-
       - name: Check whether the citation metadata from CITATION.cff is valid
         uses: citation-file-format/cffconvert-github-action@2.0.0
         with:
           args: "--validate"
 
-      - name: yaml_config used by super-linter
-        run: |
-          # TODO - very large line length
-          echo 'rules:' > yaml_config.yaml
-          echo '  line-length:' >> yaml_config.yaml
-          echo '    max: 250' >> yaml_config.yaml
-
       # Dependencies required to avoid errors
       # reported by linters
       - name: Install mamba dependencies
@@ -100,22 +83,6 @@ jobs:
         uses: super-linter/super-linter@v6
         env:
           VALIDATE_ALL_CODEBASE: false
-          # github actions
-          VALIDATE_GITHUB_ACTIONS: true
-          # yaml
-          VALIDATE_YAML: true
-          YAML_CONFIG_FILE: yaml_config.yaml
-          YAML_ERROR_ON_WARNING: false
-          # isort
-          VALIDATE_PYTHON_ISORT: true
-          PYTHON_ISORT_CONFIG_FILE: pyproject.toml
-          # flake8
-          VALIDATE_PYTHON_FLAKE8: true
-          # black
-          VALIDATE_PYTHON_BLACK: true
-          PYTHON_BLACK_CONFIG_FILE: pyproject.toml
-          # markdown
-          VALIDATE_MARKDOWN: true
           # docker
           VALIDATE_DOCKERFILE_HADOLINT: true
           # .env file
@@ -131,5 +98,3 @@ jobs:
           LOG_FILE: superlinter.log
           DEFAULT_BRANCH: main
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          # exclude link to markdown files
-          FILTER_REGEX_EXCLUDE: "docs/source/docker_files.md"
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c000d069b..5331f20d4 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,21 +1,15 @@
 repos:
-  # https://pycqa.github.io/isort/docs/configuration/black_compatibility.html#integration-with-pre-commit
-  - repo: https://github.com/pycqa/isort
-    rev: 5.13.2
-    hooks:
-      - id: isort
-        args: ["--profile", "black", "--filter-files"]
   - repo: https://github.com/psf/black
     rev: 24.4.2
     hooks:
       - id: black
         args: ["--line-length=100"]
-  # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html?highlight=other%20tools#flake8
-  - repo: https://github.com/PyCQA/flake8
-    rev: 7.0.0
+  - repo: https://github.com/astral-sh/ruff-pre-commit
+  # Ruff
+    rev: v0.4.5
     hooks:
-      - id: flake8
-        args: ["--max-line-length=100"]
+      - id: ruff
+        args: ["--fix"]
   # https://github.com/pre-commit/pre-commit-hooks
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v4.6.0
@@ -24,26 +18,13 @@ repos:
       - id: end-of-file-fixer
       - id: check-added-large-files
         args: ['--maxkb=500']
-  - repo: local
-    hooks:
-      - id: pylint
-        name: pylint
-        entry: pylint
-        language: system
-        types: [python]
-        exclude: ^tests/|^simtools/applications/db_development_tools/|docs/source/conf.py
-        args:
-          [
-            "-rn",  # Only display messages
-            "-sn",  # Don't display the score
-          ]
   # https://github.com/HunterMcGushion/docstr_coverage
   - repo: https://github.com/HunterMcGushion/docstr_coverage
     rev: v2.3.2  # most recent docstr-coverage release or commit sha
     hooks:
       - id: docstr-coverage
         args: ["--verbose", "2", "--fail-under", "70.", "simtools"]
-  # gitup action
+  # Github action
   - repo: https://github.com/rhysd/actionlint
     rev: v1.7.0
     hooks:
@@ -58,3 +39,9 @@ repos:
     rev: v2.3.0
     hooks:
       - id: codespell
+  # yamllint
+  - repo: https://github.com/adrienverge/yamllint.git
+    rev: v1.29.0
+    hooks:
+      - id: yamllint
+        args: ["--strict", "-d", '{rules: {line-length: {max: 250}}}']
diff --git a/environment.yml b/environment.yml
index 05e489b46..3655e35c2 100644
--- a/environment.yml
+++ b/environment.yml
@@ -8,7 +8,6 @@ dependencies:
   - boost-histogram
   - ctapipe
   - eventio
-  - flake8
   - jsonschema
   - matplotlib-base
   - myst-parser
diff --git a/pyproject.toml b/pyproject.toml
index 4131585e4..a5da987ad 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -43,7 +43,6 @@ dependencies = [
   "toml",
 ]
 optional-dependencies."dev" = [
-  "flake8",
   "pre-commit",
   "pylint",
   "ruff",
@@ -149,9 +148,6 @@ lint.per-file-ignores."**/tests_*.py" = [
   "D",
 ]
 
-[tool.isort]
-profile = "black"
-
 [tool.pylint.main]
 # Good variable names which should always be accepted, separated by a comma.
 good-names = [


Test patch:
diff --git a/.github/workflows/CI-unittests.yml b/.github/workflows/CI-unittests.yml
index 726c0177a..044d12843 100644
--- a/.github/workflows/CI-unittests.yml
+++ b/.github/workflows/CI-unittests.yml
@@ -1,6 +1,6 @@
 ---
 name: CI-unittests
-# Execute unit tests - flake8 and pytest
+# Execute unit tests
 #
 env:
   SIMTOOLS_DB_SERVER: ${{ secrets.DB_SERVER }}
@@ -92,10 +92,6 @@ jobs:
         run: |
           pip install -e '.[tests,dev,doc]'
 
-      - name: flake8
-        run: |
-          flake8 --max-line-length 100 --per-file-ignores="_version.py:F401 E501" .
-
       - name: Unit tests
         shell: bash -l {0}
         run: |