Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: black & isort common workflow #846

Merged
merged 24 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .github/workflows/annotation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Run isort
uses: isort/isort-action@v1.1.0
with:
configuration:
--profile=black
--filter-files
--line-length=79
- name: Black
uses: psf/black@stable
with:
options: "--line-length=79"
- run: pip install flake8
- run: flake8 --extend-ignore=E203 annotation
annotation-build:
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Run isort
uses: isort/isort-action@v1.1.0
with:
configuration:
--profile=black
--filter-files
--line-length=79
- name: Black
uses: psf/black@stable
with:
options: "--line-length=79"
- run: pip install flake8
- run: flake8 --extend-ignore=E203 assets
assets-build:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/convert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ jobs:
poetry install --all-extras
poetry add --editable ../lib/filter_lib
poetry add --editable ../lib/tenants
- name: Run linters and checkers [isort -> black -> mypy -> pylint]
- name: Run linters and checkers [mypy -> pylint]
working-directory: ./convert
run: |
git ls-files -- . | xargs pre-commit run --files
git ls-files -- . | xargs pre-commit run mypy --files
git ls-files -- . | xargs pre-commit run pylint --files
- name: Run tests
working-directory: ./convert
run: |
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/filter-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Run isort
uses: isort/isort-action@v1.1.0
with:
sort-paths: lib/filter_lib/*
configuration:
--check-only
--profile=black
--line-length=79
--skip=tests
- name: Black
uses: psf/black@stable
with:
src: "lib/filter_lib"
options: '--check --line-length=79 --exclude="tests" --verbose'
- run: pip install flake8
- run: flake8 --exclude=tests --extend-ignore=E203 lib/filter_lib
filter-lib-build:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ jobs:
poetry install --no-root
poetry add ../lib/filter_lib
poetry add ../lib/tenants
- name: Run linters and checkers [flake8 -> isort -> black]
- name: Run linters and checkers [flake8]
working-directory: ./jobs
run: |
poetry run flake8 --extend-ignore=E203 jobs/
poetry run isort --profile=black --line-length=79 --check-only jobs/
poetry run black --check --line-length=79 jobs/
- name: Run tests
working-directory: ./jobs
run: |
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lint
on:
pull_request:
paths:
- "**.py"
- ".github/workflows/lint.yml"

env:
PYTHON_VERSION: 3.8
LINT_CONFIG: pyproject.toml


jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --only dev
- name: Run Isort
run: |
poetry run isort --diff --check-only .
- name: Run Black
run: |
poetry run black --config $LINT_CONFIG --diff --check .
11 changes: 0 additions & 11 deletions .github/workflows/processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Run isort
uses: isort/isort-action@v1.1.0
with:
configuration:
--profile=black
--filter-files
--line-length=79
- name: Black
uses: psf/black@stable
with:
options: "--line-length=79"
- run: pip install flake8
- run: flake8 --extend-ignore=E203 processing

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/taxonomy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ jobs:
poetry install --no-root
poetry add ../lib/filter_lib
poetry add ../lib/tenants
- name: Run linters and checkers [flake8 -> isort -> black]
- name: Run linters and checkers [flake8]
working-directory: ./taxonomy
run: |
poetry run flake8 --extend-ignore=E203 taxonomy/
poetry run isort --profile=black --line-length=79 --check-only taxonomy/
poetry run black --check --line-length=79 taxonomy/
- name: Run tests
working-directory: ./taxonomy
run: |
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/tenants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Run isort
uses: isort/isort-action@v1.1.0
with:
sort-paths: lib/tenants/*
configuration:
--check-only
--profile=black
--line-length=79
--skip=tests
- name: Black
uses: psf/black@stable
with:
src: "lib/tenants"
options: '--check --line-length=79 --exclude="tests" --verbose'
- run: pip install flake8
- run: flake8 --exclude=tests --extend-ignore=E203 lib/tenants
tenants-build:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ jobs:
pip install poetry>=1.1.13
poetry install --no-root
poetry add ../lib/tenants
- name: Run linters and checkers [flake8 -> isort -> black]
- name: Run linters and checkers [flake8]
working-directory: ./users
run: |
poetry run flake8 --extend-ignore=E203 users/
poetry run isort --profile=black --line-length=79 --check-only users/
poetry run black --check --line-length=79 users/
- name: Run tests
working-directory: ./users
run: |
Expand Down
2 changes: 1 addition & 1 deletion airflow/dags/print_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime
from pprint import pprint

from airflow.decorators import task, dag
from airflow.decorators import dag, task


@dag(schedule="@daily", start_date=datetime(2021, 12, 1), catchup=False, dag_id="print")
Expand Down
2 changes: 1 addition & 1 deletion annotation/alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
from logging.config import fileConfig

from alembic import context # type: ignore
from sqlalchemy import engine_from_config, pool

from alembic import context # type: ignore
from annotation.database import SQLALCHEMY_DATABASE_URL
from annotation.utils import get_test_db_url

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "1edef72a5043"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""

import sqlalchemy as sa
from sqlalchemy.engine.reflection import Inspector

from alembic import op
from sqlalchemy.engine.reflection import Inspector

# revision identifiers, used by Alembic.
revision = "2b3ed53127ea"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "3136551008d8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from enum import Enum

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "36bff2d016f7"
Expand Down
3 changes: 1 addition & 2 deletions annotation/alembic/versions/3a083a1fbba0_first_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
from sqlalchemy.engine.reflection import Inspector

from alembic import op

# revision identifiers, used by Alembic.
revision = "3a083a1fbba0"
down_revision = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from enum import Enum

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "416952520dc1"
Expand Down
3 changes: 1 addition & 2 deletions annotation/alembic/versions/4272d0a43ff1_agreement_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "4272d0a43ff1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "4cd10ac49cc2"
Expand Down
3 changes: 1 addition & 2 deletions annotation/alembic/versions/615379303da2_added_links_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "615379303da2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "62470ebd1429"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import sqlalchemy as sa
import sqlalchemy_utils

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

import sqlalchemy as sa

from alembic import op

from annotation.models import ValidationSchema

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"""

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "8fbac489cef2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from enum import Enum

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "9c07a25ca06f"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Loading
Loading