From 0bc173a328525f5b6ec9767641d384c02d5b615d Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 4 Jan 2024 14:57:50 +0100 Subject: [PATCH 1/8] feat: initial added black lint workflow --- .github/workflows/lint.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..edd3be38 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,16 @@ +name: Lint + +on: + push: + branches: + - main + pull_request: + +jobs: + black: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: psf/black@stable + with: + options: "--check --verbose" From 8366dc96b4a981ff2bca55a5c433908b10a9dad5 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:04:37 +0100 Subject: [PATCH 2/8] ci: remove options use defaults --- .github/workflows/lint.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index edd3be38..d7d16190 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,5 +12,3 @@ jobs: steps: - uses: actions/checkout@v4 - uses: psf/black@stable - with: - options: "--check --verbose" From 6d7e5d8dc3980730c4260575f9074caba0b52914 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:17:33 +0100 Subject: [PATCH 3/8] chore: changelog fragment --- changelogs/fragments/339-lint-black.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/339-lint-black.yml diff --git a/changelogs/fragments/339-lint-black.yml b/changelogs/fragments/339-lint-black.yml new file mode 100644 index 00000000..2a37ca85 --- /dev/null +++ b/changelogs/fragments/339-lint-black.yml @@ -0,0 +1,3 @@ +--- +trivial: + - added python black linting action From 6f5f3f74f265c9ef26bbb7efddcc59adf736cd4e Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:34:36 +0100 Subject: [PATCH 4/8] ci: get changed files --- .github/workflows/lint.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d7d16190..a144cc8e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,4 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: **/*.py + - uses: psf/black@stable From 5caa7bd4644fe50cc3944ed628ee15ac2c28571b Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:35:15 +0100 Subject: [PATCH 5/8] ci: black src to changed files --- .github/workflows/lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a144cc8e..ccd5ef57 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,3 +19,4 @@ jobs: files: **/*.py - uses: psf/black@stable + src: ${{ steps.changed-files.outputs.all_changed_files }} From 7b9802fc3375ea427248505a43895a14ed9dc0d3 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:37:04 +0100 Subject: [PATCH 6/8] chore: black lint python files --- plugins/callback/grafana_annotations.py | 2 -- plugins/doc_fragments/api_key.py | 1 - plugins/doc_fragments/basic_auth.py | 1 - plugins/lookup/grafana_dashboard.py | 1 - plugins/modules/grafana_dashboard.py | 4 ---- plugins/modules/grafana_folder.py | 1 - plugins/modules/grafana_team.py | 1 - 7 files changed, 11 deletions(-) diff --git a/plugins/callback/grafana_annotations.py b/plugins/callback/grafana_annotations.py index c488505c..6030b0c8 100644 --- a/plugins/callback/grafana_annotations.py +++ b/plugins/callback/grafana_annotations.py @@ -167,7 +167,6 @@ class CallbackModule(CallbackBase): CALLBACK_NEEDS_WHITELIST = True def __init__(self, display=None): - super(CallbackModule, self).__init__(display=display) self.headers = {"Content-Type": "application/json"} @@ -178,7 +177,6 @@ def __init__(self, display=None): self.errors = 0 def set_options(self, task_keys=None, var_options=None, direct=None): - super(CallbackModule, self).set_options( task_keys=task_keys, var_options=var_options, direct=direct ) diff --git a/plugins/doc_fragments/api_key.py b/plugins/doc_fragments/api_key.py index aa2e30c2..94fdb57a 100644 --- a/plugins/doc_fragments/api_key.py +++ b/plugins/doc_fragments/api_key.py @@ -8,7 +8,6 @@ class ModuleDocFragment(object): - DOCUMENTATION = r"""options: grafana_api_key: description: diff --git a/plugins/doc_fragments/basic_auth.py b/plugins/doc_fragments/basic_auth.py index 6efe48c4..5a8aec54 100644 --- a/plugins/doc_fragments/basic_auth.py +++ b/plugins/doc_fragments/basic_auth.py @@ -8,7 +8,6 @@ class ModuleDocFragment(object): - DOCUMENTATION = r"""options: url: description: diff --git a/plugins/lookup/grafana_dashboard.py b/plugins/lookup/grafana_dashboard.py index 7105ce0a..c7fa3157 100644 --- a/plugins/lookup/grafana_dashboard.py +++ b/plugins/lookup/grafana_dashboard.py @@ -175,7 +175,6 @@ def grafana_list_dashboards(self): class LookupModule(LookupBase): def run(self, terms, variables=None, **kwargs): - grafana_args = terms[0].split(" ") grafana_dict = {} ret = [] diff --git a/plugins/modules/grafana_dashboard.py b/plugins/modules/grafana_dashboard.py index 8ae8eb4f..d8075252 100644 --- a/plugins/modules/grafana_dashboard.py +++ b/plugins/modules/grafana_dashboard.py @@ -285,7 +285,6 @@ def grafana_dashboard_exists(module, grafana_url, uid, headers): def grafana_dashboard_search(module, grafana_url, folder_id, title, headers): - # search by title uri = "%s/api/search?%s" % ( grafana_url, @@ -339,7 +338,6 @@ def grafana_dashboard_changed(payload, dashboard): def grafana_create_dashboard(module, data): - # define data payload for grafana API payload = {} if data.get("dashboard_id"): @@ -482,7 +480,6 @@ def grafana_create_dashboard(module, data): def grafana_delete_dashboard(module, data): - # define http headers headers = grafana_headers(module, data) @@ -540,7 +537,6 @@ def grafana_delete_dashboard(module, data): def grafana_export_dashboard(module, data): - # define http headers headers = grafana_headers(module, data) diff --git a/plugins/modules/grafana_folder.py b/plugins/modules/grafana_folder.py index 07a3400a..99971b83 100644 --- a/plugins/modules/grafana_folder.py +++ b/plugins/modules/grafana_folder.py @@ -285,7 +285,6 @@ def setup_module_object(): def main(): - module = setup_module_object() state = module.params["state"] title = module.params["name"] diff --git a/plugins/modules/grafana_team.py b/plugins/modules/grafana_team.py index 787b4345..c2d543d8 100644 --- a/plugins/modules/grafana_team.py +++ b/plugins/modules/grafana_team.py @@ -324,7 +324,6 @@ def setup_module_object(): def main(): - module = setup_module_object() state = module.params["state"] name = module.params["name"] From 926580df153a03d83e8a811ccd0942206e77b4fd Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:46:05 +0100 Subject: [PATCH 7/8] ci: quote with files glob pattern --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ccd5ef57..c8b867bd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: id: changed-files uses: tj-actions/changed-files@v41 with: - files: **/*.py + files: "**/*.py" - uses: psf/black@stable src: ${{ steps.changed-files.outputs.all_changed_files }} From b48a39079ef93aead1d56a1b80a6cc171a3e4e2e Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:48:58 +0100 Subject: [PATCH 8/8] ci: missed with def before src --- .github/workflows/lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c8b867bd..dae17580 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,4 +19,5 @@ jobs: files: "**/*.py" - uses: psf/black@stable - src: ${{ steps.changed-files.outputs.all_changed_files }} + with: + src: ${{ steps.changed-files.outputs.all_changed_files }}