From 771e57c166f6516c4a518d5960ff1371b254b038 Mon Sep 17 00:00:00 2001 From: Tyler Matteson Date: Tue, 5 Mar 2024 13:35:28 -0500 Subject: [PATCH] ci: add frappe black to CI (#214) * ci: add frappe black to CI * chore: black, flake8 --- .github/workflows/lint.yaml | 31 ++++++++++--- .../payables_attachments.py | 44 ++++++++++++------- .../patches/patch_voided_check_workflow.py | 3 +- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 25c8b7d1..996344e7 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -32,12 +32,33 @@ jobs: - name: Install mypy run: pip install mypy - - name: Run mypy - uses: sasanquaneuf/mypy-github-action@releases/v1 + # - name: Run mypy + # uses: sasanquaneuf/mypy-github-action@releases/v1 + # with: + # checkName: 'mypy' + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + black: + needs: [ py_json_merge ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 with: - checkName: 'mypy' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ github.head_ref }} + fetch-depth: 2 + + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + + - name: Install Black (Frappe) + run: pip install git+https://github.com/frappe/black.git + + - name: Run Black (Frappe) + run: black --check . json_diff: needs: [ py_json_merge ] diff --git a/check_run/check_run/report/payables_attachments/payables_attachments.py b/check_run/check_run/report/payables_attachments/payables_attachments.py index b479a7be..548b7389 100644 --- a/check_run/check_run/report/payables_attachments/payables_attachments.py +++ b/check_run/check_run/report/payables_attachments/payables_attachments.py @@ -10,30 +10,45 @@ def execute(filters=None): return get_columns(filters), get_data(filters) + def get_data(filters): PurchaseInvoice = DocType("Purchase Invoice") data = ( frappe.qb.from_(PurchaseInvoice) - .select( - PurchaseInvoice.name, PurchaseInvoice.title, PurchaseInvoice.supplier, PurchaseInvoice.company, - PurchaseInvoice.posting_date, PurchaseInvoice.grand_total, PurchaseInvoice.status, PurchaseInvoice.currency, - PurchaseInvoice.supplier_name, PurchaseInvoice.grand_total, PurchaseInvoice.outstanding_amount, - PurchaseInvoice.due_date, PurchaseInvoice.is_return, PurchaseInvoice.release_date, PurchaseInvoice.represents_company, - PurchaseInvoice.is_internal_supplier - ) - .orderby('modified', Order.desc) + .select( + PurchaseInvoice.name, + PurchaseInvoice.title, + PurchaseInvoice.supplier, + PurchaseInvoice.company, + PurchaseInvoice.posting_date, + PurchaseInvoice.grand_total, + PurchaseInvoice.status, + PurchaseInvoice.currency, + PurchaseInvoice.supplier_name, + PurchaseInvoice.grand_total, + PurchaseInvoice.outstanding_amount, + PurchaseInvoice.due_date, + PurchaseInvoice.is_return, + PurchaseInvoice.release_date, + PurchaseInvoice.represents_company, + PurchaseInvoice.is_internal_supplier, + ) + .orderby("modified", Order.desc) ).run(as_dict=True) - + for row in data: - row['attachments'] = " ".join([ - f"""{attachment.file_name}""" - for attachment in get_attachments('Purchase Invoice', row['name']) if attachment.file_url.endswith('.pdf') - ]) + row["attachments"] = " ".join( + [ + f"""{attachment.file_name}""" + for attachment in get_attachments("Purchase Invoice", row["name"]) + if attachment.file_url.endswith(".pdf") + ] + ) return data + def get_columns(filters): return [ - { "label": frappe._("Name"), "fieldname": "name", @@ -142,4 +157,3 @@ def get_columns(filters): "width": "400px", }, ] - diff --git a/check_run/patches/patch_voided_check_workflow.py b/check_run/patches/patch_voided_check_workflow.py index 8872e951..0740c4b7 100644 --- a/check_run/patches/patch_voided_check_workflow.py +++ b/check_run/patches/patch_voided_check_workflow.py @@ -1,6 +1,5 @@ -import frappe from check_run.customize import add_workflow_for_voided_check def execute(): - add_workflow_for_voided_check() \ No newline at end of file + add_workflow_for_voided_check()