Skip to content

Commit

Permalink
Merge pull request #327 from VariantEffect/feature/bencap/267/lint-wi…
Browse files Browse the repository at this point in the history
…th-ruff

Lint and Format with Ruff
  • Loading branch information
bencap authored Oct 11, 2024
2 parents 96f5d1a + c76ed51 commit 356d377
Show file tree
Hide file tree
Showing 171 changed files with 1,899 additions and 1,615 deletions.
11 changes: 0 additions & 11 deletions .flake8

This file was deleted.

14 changes: 14 additions & 0 deletions .github/workflows/run-tests-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,17 @@ jobs:
- run: pip install poetry
- run: poetry install --with dev --extras server
- run: poetry run mypy src/

run-ruff-lint:
runs-on: ubuntu-latest
name: Ruff linting on Python 3.10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
- run: pip install --upgrade pip
- run: pip install poetry
- run: poetry install --with dev --extras server
- run: poetry run ruff check
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.8
hooks:
- id: black
# Latest version of Python supported by the project
# See https://pre-commit.com/#top_level-default_language_version
language_version: python3.9
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
3 changes: 2 additions & 1 deletion alembic/alembic_helpers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# From https://improveandrepeat.com/2021/09/python-friday-87-handling-pre-existing-tables-with-alembic-and-sqlalchemy/
# Based on https://github.com/talkpython/data-driven-web-apps-with-flask

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

from alembic import op


def table_does_not_exist(table, schema=None):
config = op.get_context().config
Expand Down
5 changes: 2 additions & 3 deletions alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from logging.config import fileConfig
import os
from logging.config import fileConfig

from sqlalchemy import engine_from_config
from sqlalchemy import pool
from sqlalchemy import engine_from_config, pool

from alembic import context

Expand Down
3 changes: 1 addition & 2 deletions alembic/versions/194cfebabe32_rename_wild_type_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-08-29 12:48:18.390567
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "194cfebabe32"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2024-09-03 09:53:21.635751
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "1cee01c42909"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
Create Date: 2024-09-04 16:17:20.875937
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1d4933b4b6f7'
down_revision = ('76e1e55bc5c1', 'd7e6f8c3b9dc')
revision = "1d4933b4b6f7"
down_revision = ("76e1e55bc5c1", "d7e6f8c3b9dc")
branch_labels = None
depends_on = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
Create Date: 2023-06-01 14:51:04.700969
"""
from typing import Optional

import os
from typing import Optional

import eutils
from eutils._internal.xmlfacades.pubmedarticleset import PubmedArticleSet
import sqlalchemy as sa
from eutils import EutilsNCBIError
from mavedb.lib.exceptions import AmbiguousIdentifierError
from eutils._internal.xmlfacades.pubmedarticleset import PubmedArticleSet
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import Session

from alembic import op
from mavedb.lib.identifiers import ExternalPublication
from mavedb.lib.exceptions import AmbiguousIdentifierError
from mavedb.lib.external_publications import Rxiv
from mavedb.lib.identifiers import ExternalPublication
from mavedb.models.publication_identifier import PublicationIdentifier

# revision identifiers, used by Alembic.
Expand Down
4 changes: 3 additions & 1 deletion alembic/versions/2b6f40ea2fb6_add_score_range_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
Create Date: 2024-09-09 12:25:33.180077
"""
from alembic import op

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op

# revision identifiers, used by Alembic.
revision = "2b6f40ea2fb6"
down_revision = "1cee01c42909"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Create Date: 2024-05-16 13:06:05.561411
"""
from alembic import op

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "2c8d7e2bf2fe"
Expand Down
32 changes: 19 additions & 13 deletions alembic/versions/33e99d4b90cc_add_mapped_variants_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,39 @@
Create Date: 2023-05-15 17:24:07.847206
"""
from alembic import op

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op

# revision identifiers, used by Alembic.
revision = '33e99d4b90cc'
down_revision = 'da9ba478647d'
revision = "33e99d4b90cc"
down_revision = "da9ba478647d"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('mapped_variants',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pre_mapped', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column('post_mapped', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column('variant_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['variant_id'], ['variants.id'], ),
sa.PrimaryKeyConstraint('id')
op.create_table(
"mapped_variants",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("pre_mapped", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("post_mapped", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("variant_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["variant_id"],
["variants.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f('ix_mapped_variants_id'), 'mapped_variants', ['id'], unique=False)
op.create_index(op.f("ix_mapped_variants_id"), "mapped_variants", ["id"], unique=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_mapped_variants_id'), table_name='mapped_variants')
op.drop_table('mapped_variants')
op.drop_index(op.f("ix_mapped_variants_id"), table_name="mapped_variants")
op.drop_table("mapped_variants")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Create Date: 2024-04-18 09:19:04.008237
"""
from alembic import op

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "377bb8c30bde"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Create Date: 2024-08-16 13:25:14.980820
"""

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "44a45d616036"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Create Date: 2023-08-24 15:20:01.208691
"""
from alembic import op

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "44d5c568f64b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Create Date: 2023-05-09 16:18:41.360541
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "5cad62af3705"
Expand Down
3 changes: 2 additions & 1 deletion alembic/versions/60103ad1cb5b_add_target_sequence_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Create Date: 2023-08-29 16:04:44.620385
"""
from alembic import op

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "60103ad1cb5b"
Expand Down
3 changes: 2 additions & 1 deletion alembic/versions/6fae83d65ee4_taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Create Date: 2023-12-21 18:06:18.912925
"""
from alembic import op

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "6fae83d65ee4"
Expand Down
89 changes: 56 additions & 33 deletions alembic/versions/76e1e55bc5c1_add_contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,75 @@
Create Date: 2024-08-22 06:17:03.265438
"""
from alembic import op

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = '76e1e55bc5c1'
down_revision = '9702d32bacb3'
revision = "76e1e55bc5c1"
down_revision = "9702d32bacb3"
branch_labels = None
depends_on = None


def upgrade():
op.create_table('contributors',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('orcid_id', sa.String(), nullable=False),
sa.Column('given_name', sa.String(), nullable=True),
sa.Column('family_name', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('id')
op.create_table(
"contributors",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("orcid_id", sa.String(), nullable=False),
sa.Column("given_name", sa.String(), nullable=True),
sa.Column("family_name", sa.String(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f('ix_contributors_orcid_id'), 'contributors', ['orcid_id'], unique=False)
op.create_table('experiment_set_contributors',
sa.Column('experiment_set_id', sa.Integer(), nullable=False),
sa.Column('contributor_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['contributor_id'], ['contributors.id'], ),
sa.ForeignKeyConstraint(['experiment_set_id'], ['experiment_sets.id'], ),
sa.PrimaryKeyConstraint('experiment_set_id', 'contributor_id')
op.create_index(op.f("ix_contributors_orcid_id"), "contributors", ["orcid_id"], unique=False)
op.create_table(
"experiment_set_contributors",
sa.Column("experiment_set_id", sa.Integer(), nullable=False),
sa.Column("contributor_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["contributor_id"],
["contributors.id"],
),
sa.ForeignKeyConstraint(
["experiment_set_id"],
["experiment_sets.id"],
),
sa.PrimaryKeyConstraint("experiment_set_id", "contributor_id"),
)
op.create_table('experiment_contributors',
sa.Column('experiment_id', sa.Integer(), nullable=False),
sa.Column('contributor_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['contributor_id'], ['contributors.id'], ),
sa.ForeignKeyConstraint(['experiment_id'], ['experiments.id'], ),
sa.PrimaryKeyConstraint('experiment_id', 'contributor_id')
op.create_table(
"experiment_contributors",
sa.Column("experiment_id", sa.Integer(), nullable=False),
sa.Column("contributor_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["contributor_id"],
["contributors.id"],
),
sa.ForeignKeyConstraint(
["experiment_id"],
["experiments.id"],
),
sa.PrimaryKeyConstraint("experiment_id", "contributor_id"),
)
op.create_table('scoreset_contributors',
sa.Column('scoreset_id', sa.Integer(), nullable=False),
sa.Column('contributor_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['contributor_id'], ['contributors.id'], ),
sa.ForeignKeyConstraint(['scoreset_id'], ['scoresets.id'], ),
sa.PrimaryKeyConstraint('scoreset_id', 'contributor_id')
op.create_table(
"scoreset_contributors",
sa.Column("scoreset_id", sa.Integer(), nullable=False),
sa.Column("contributor_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["contributor_id"],
["contributors.id"],
),
sa.ForeignKeyConstraint(
["scoreset_id"],
["scoresets.id"],
),
sa.PrimaryKeyConstraint("scoreset_id", "contributor_id"),
)


def downgrade():
op.drop_table('scoreset_contributors')
op.drop_table('experiment_contributors')
op.drop_table('experiment_set_contributors')
op.drop_index(op.f('ix_contributors_orcid_id'), table_name='contributors')
op.drop_table('contributors')
op.drop_table("scoreset_contributors")
op.drop_table("experiment_contributors")
op.drop_table("experiment_set_contributors")
op.drop_index(op.f("ix_contributors_orcid_id"), table_name="contributors")
op.drop_table("contributors")
Loading

0 comments on commit 356d377

Please sign in to comment.