From 98294edceb433ad3d4060fa771105bdd2e1c6605 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Mon, 13 Nov 2023 14:04:35 -0600 Subject: [PATCH] cicd: use ruff for autoformatting (#292) --- .github/workflows/github-actions.yml | 13 +++++++++---- .pre-commit-config.yaml | 9 ++------- Pipfile | 3 +-- pyproject.toml | 3 ++- src/gene/database/postgresql.py | 10 +++++++--- src/gene/schemas.py | 3 +-- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index da38a429..da14c709 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -6,11 +6,16 @@ jobs: steps: - uses: actions/checkout@v3 - - name: black - uses: psf/black@stable + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install dependencies + run: python3 -m pip install ".[dev]" - - name: ruff - uses: chartboost/ruff-action@v1 + - name: Check style + run: python3 -m ruff check . && python3 -m ruff format --check . test: runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6767f6cb..2b0ba8a9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,13 +7,8 @@ repos: - id: detect-private-key - id: trailing-whitespace - id: end-of-file-fixer -- repo: https://github.com/psf/black - rev: 23.7.0 - hooks: - - id: black - language_version: python3.11 - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.290 + rev: v0.1.2 hooks: - id: ruff - args: [ --fix, --exit-non-zero-on-fix ] + - id: ruff-format diff --git a/Pipfile b/Pipfile index aed3a8de..5ed5972f 100644 --- a/Pipfile +++ b/Pipfile @@ -18,8 +18,7 @@ gffutils = "*" psycopg = {version = "*", extras=["binary"]} pytest = "*" pre-commit = "*" -black = "*" -ruff = "*" +ruff = ">=0.1.2" pytest-cov = "*" httpx = "*" mock = "*" diff --git a/pyproject.toml b/pyproject.toml index ca67c218..8f54c725 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ etl = ["gffutils", "biocommons.seqrepo"] test = ["pytest>=6.0", "pytest-cov", "mock", "httpx"] -dev = ["pre-commit", "black", "ruff"] +dev = ["pre-commit", "ruff>=0.1.2"] docs = [ "sphinx==6.1.3", @@ -92,6 +92,7 @@ extend-exclude = "^/docs/source/conf.py" [tool.ruff] src = ["src"] +exclude = ["docs/source/conf.py"] # pycodestyle (E, W) # Pyflakes (F) # flake8-annotations (ANN) diff --git a/src/gene/database/postgresql.py b/src/gene/database/postgresql.py index c699cd20..f62a1819 100644 --- a/src/gene/database/postgresql.py +++ b/src/gene/database/postgresql.py @@ -546,12 +546,16 @@ def add_source_metadata(self, src_name: SourceName, meta: SourceMeta) -> None: VALUES (%s, %s, %s, %s, %s, %s, %s, %s); """ _ins_symbol_query = ( - b"INSERT INTO gene_symbols (symbol, concept_id) VALUES (%s, %s);" # noqa: E501 + b"INSERT INTO gene_symbols (symbol, concept_id) VALUES (%s, %s);" + ) + _ins_prev_symbol_query = ( + b"INSERT INTO gene_previous_symbols (prev_symbol, concept_id) VALUES (%s, %s);" ) - _ins_prev_symbol_query = b"INSERT INTO gene_previous_symbols (prev_symbol, concept_id) VALUES (%s, %s);" # noqa: E501 _ins_alias_query = b"INSERT INTO gene_aliases (alias, concept_id) VALUES (%s, %s);" _ins_xref_query = b"INSERT INTO gene_xrefs (xref, concept_id) VALUES (%s, %s);" - _ins_assoc_query = b"INSERT INTO gene_associations (associated_with, concept_id) VALUES (%s, %s);" # noqa: E501 + _ins_assoc_query = ( + b"INSERT INTO gene_associations (associated_with, concept_id) VALUES (%s, %s);" + ) def add_record(self, record: Dict, src_name: SourceName) -> None: """Add new record to database. diff --git a/src/gene/schemas.py b/src/gene/schemas.py index ab49faab..6f85b1bc 100644 --- a/src/gene/schemas.py +++ b/src/gene/schemas.py @@ -94,8 +94,7 @@ class BaseGene(BaseModel): strand: Optional[Strand] = None location_annotations: List[StrictStr] = [] locations: Union[ - List[models.SequenceLocation], - List[GeneSequenceLocation] + List[models.SequenceLocation], List[GeneSequenceLocation] # List[Union[SequenceLocation, ChromosomeLocation]], # List[Union[GeneSequenceLocation, GeneChromosomeLocation]] # dynamodb ] = []