From 6cb1d6b528c93d9d3eb355d1f94234484c737024 Mon Sep 17 00:00:00 2001
From: Dorian Turba <froggit.commit.z3jqj@simplelogin.com>
Date: Mon, 10 Jul 2023 11:30:43 +0200
Subject: [PATCH] add isort

---
 isort.r2.yml                        | 14 +++++++++
 python/code_quality/isort/README.md | 49 +++++++++++++++++++++++++++++
 python/code_quality/isort/isort.yml | 14 +++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 isort.r2.yml
 create mode 100644 python/code_quality/isort/README.md
 create mode 100644 python/code_quality/isort/isort.yml

diff --git a/isort.r2.yml b/isort.r2.yml
new file mode 100644
index 0000000..2d59d75
--- /dev/null
+++ b/isort.r2.yml
@@ -0,0 +1,14 @@
+files:
+    template: ./python/code_quality/isort/isort.yml
+    documentation: ./python/code_quality/isort/README.md
+data:
+    description: "Run isort on your repository"
+    icon: 💎
+    public: true
+    labels:
+        - Lint
+        - Utilities
+        - Code Quality
+        - Python
+    license: MIT
+    deprecated: false
diff --git a/python/code_quality/isort/README.md b/python/code_quality/isort/README.md
new file mode 100644
index 0000000..f386fb2
--- /dev/null
+++ b/python/code_quality/isort/README.md
@@ -0,0 +1,49 @@
+## Objective
+
+Run [isort](https://pycqa.github.io/isort/) on your Python code to automatically sort and organize
+your imports. isort separates imports into sections and by type. It's a helpful tool to ensure that
+your code remains clean and readable.
+
+### Global Configuration of isort
+
+To add configuration to `isort` shared with any other usage of isort (such as manual run,
+pre-commit, etc), you can use `pyproject.toml` configuration file or a dedicated `.isort.cfg`. Learn
+more about [isort configuration](https://pycqa.github.io/isort/docs/configuration/config_files.html)
+files.
+
+Here's an example configuration for `pyproject.toml`:
+
+```toml
+[tool.isort]
+profile = "black"
+line_length = 100
+```
+
+And for `.isort.cfg`:
+
+```cfg
+[settings]
+profile=hug
+line_length=100
+```
+
+These examples set the line length to 100 characters and use the "black" profile, which is designed
+to work well with the `black` auto-formatter.
+
+## How to use it
+
+1. Configure the `pyproject.toml` or `.isort.cfg` file in your repository's root directory with your
+   desired rules.
+2. Include the isort template in your CI/CD configuration (see quick use above).
+3. If you need to customize the job, check
+   the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization).
+
+## Add an <a href="https://pycqa.github.io/isort/"><img alt="Imports: isort" src="https://img.shields.io/badge/Imports-isort-yellow"></a> Badge to your project README.md
+
+To display the use of isort in your project, you can add the following badge to your README.md:
+
+```markdown
+<a href="https://pycqa.github.io/isort/">
+    <img alt="Imports: isort" src="https://img.shields.io/badge/Imports-isort-yellow">
+</a>
+```
diff --git a/python/code_quality/isort/isort.yml b/python/code_quality/isort/isort.yml
new file mode 100644
index 0000000..9da0609
--- /dev/null
+++ b/python/code_quality/isort/isort.yml
@@ -0,0 +1,14 @@
+isort:
+    image: python:latest
+    stage: code_quality
+    script:
+        - python --version  # Debug
+        - python -m venv venv --upgrade-deps || python -m venv venv  # upgrade-deps is not supported before 3.9
+        - source venv/bin/activate
+        - pip install isort
+        - isort . --diff
+    only:
+        changes:
+            - ./**/*.py
+            - .gitlab-ci.yml
+            - pyproject.toml
-- 
GitLab