Skip to content

Commit

Permalink
cicd: use ruff for autoformatting (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson authored Nov 13, 2023
1 parent cae10d7 commit 98294ed
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ gffutils = "*"
psycopg = {version = "*", extras=["binary"]}
pytest = "*"
pre-commit = "*"
black = "*"
ruff = "*"
ruff = ">=0.1.2"
pytest-cov = "*"
httpx = "*"
mock = "*"
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions src/gene/database/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions src/gene/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
] = []
Expand Down

0 comments on commit 98294ed

Please sign in to comment.