diff --git a/.github/workflows/presubmit.yaml b/.github/workflows/presubmit.yaml index 6c3677c..6124d48 100644 --- a/.github/workflows/presubmit.yaml +++ b/.github/workflows/presubmit.yaml @@ -23,7 +23,7 @@ jobs: - name: Install dependencies run: pip install -e .[dev] - name: Check formatting - run: nox -s format + run: nox -s lint test: name: Test (Python ${{ matrix.python-version }}) diff --git a/notebooks/audience_e2e_advertiser_flow.ipynb b/notebooks/audience_e2e_advertiser_flow.ipynb index 76037e5..d848de5 100644 --- a/notebooks/audience_e2e_advertiser_flow.ipynb +++ b/notebooks/audience_e2e_advertiser_flow.ipynb @@ -485,8 +485,10 @@ " print(f\"{ingest_res}\")\n", "\n", " if ingest_res.field_warnings:\n", - " print(\"Request ingested successfully, but field warnings were returned. \"\n", - " \"Review warning details and update your implementation as needed.\")\n", + " print(\n", + " \"Request ingested successfully, but field warnings were returned. \"\n", + " \"Review warning details and update your implementation as needed.\"\n", + " )\n", "\n", " except Exception as e:\n", " print(f\"Failed to ingest data: {e}\")\n", diff --git a/notebooks/audience_e2e_data_partner_dual_persona.ipynb b/notebooks/audience_e2e_data_partner_dual_persona.ipynb index 92426cb..9fc1bbb 100644 --- a/notebooks/audience_e2e_data_partner_dual_persona.ipynb +++ b/notebooks/audience_e2e_data_partner_dual_persona.ipynb @@ -656,8 +656,10 @@ " print(f\"{ingest_res}\")\n", "\n", " if ingest_res.field_warnings:\n", - " print(\"Request ingested successfully, but field warnings were returned. \"\n", - " \"Review warning details and update your implementation as needed.\")\n", + " print(\n", + " \"Request ingested successfully, but field warnings were returned. \"\n", + " \"Review warning details and update your implementation as needed.\"\n", + " )\n", "\n", " except Exception as e:\n", " print(f\"Failed to ingest data: {e}\")\n", diff --git a/notebooks/audience_e2e_data_partner_simplified.ipynb b/notebooks/audience_e2e_data_partner_simplified.ipynb index aa0ea6f..8b11bb8 100644 --- a/notebooks/audience_e2e_data_partner_simplified.ipynb +++ b/notebooks/audience_e2e_data_partner_simplified.ipynb @@ -497,8 +497,10 @@ " print(f\"{ingest_res}\")\n", "\n", " if ingest_res.field_warnings:\n", - " print(\"Request ingested successfully, but field warnings were returned. \"\n", - " \"Review warning details and update your implementation as needed.\")\n", + " print(\n", + " \"Request ingested successfully, but field warnings were returned. \"\n", + " \"Review warning details and update your implementation as needed.\"\n", + " )\n", "\n", " except Exception as e:\n", " print(f\"Failed to ingest data: {e}\")\n", diff --git a/noxfile.py b/noxfile.py index cdf45dd..eea9842 100644 --- a/noxfile.py +++ b/noxfile.py @@ -55,10 +55,24 @@ def tests(session): session.run(*COVERAGE_COMMAND) +def _format(session, check=False): + black_command = ["black"] + if check: + black_command.append("--check") + black_command.append(".") + session.run(*black_command) + + +@nox.session(venv_backend="none") +def lint(session): + """Fails if the code is not formatted correctly.""" + _format(session, check=True) + + @nox.session(venv_backend="none") def format(session): """Runs the black formatter and applies formatting fixes.""" - session.run("black", ".") + _format(session) @nox.session(python="3.12")