Skip to content

Commit

Permalink
style: update ruff configs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Nov 13, 2024
1 parent 65428eb commit 59af2a0
Show file tree
Hide file tree
Showing 140 changed files with 347 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
run: python3 -m pip install ".[dev]"

- name: Check style
run: python3 -m ruff check . && ruff format --check .
run: python3 -m ruff check . && python3 -m ruff format --check .
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.5.0
hooks:
- id: ruff-format
- id: ruff
Expand Down
1 change: 1 addition & 0 deletions codebuild/deploy_eb_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to deploy to staging EB environment."""

import time

import boto3
Expand Down
1 change: 1 addition & 0 deletions codebuild/deploy_eb_env_dev.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to deploy to staging EB environment."""

import time

import boto3
Expand Down
1 change: 1 addition & 0 deletions codebuild/terminate_eb_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for terminating EB staging environment."""

import json
import time

Expand Down
1 change: 1 addition & 0 deletions codebuild/terminate_eb_env_dev.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for terminating EB staging environment."""

import json
import time

Expand Down
123 changes: 78 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dynamic = ["version"]

[project.optional-dependencies]
test = ["pytest>=6.0", "pytest-cov", "pytest-asyncio"]
dev = ["pre-commit", "ruff==0.2.0", "psycopg2-binary", "jupyter", "ipykernel"]
dev = ["pre-commit", "ruff==0.5.0", "psycopg2-binary", "jupyter", "ipykernel"]

[project.urls]
Homepage = "https://github.com/cancervariants/variation-normalization"
Expand Down Expand Up @@ -75,50 +75,60 @@ src = ["src"]

[tool.ruff.lint]
select = [
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"I", # https://docs.astral.sh/ruff/rules/#isort-i
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
"D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
"S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
"G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
"Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"I", # https://docs.astral.sh/ruff/rules/#isort-i
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
"D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
"S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
"LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log
"G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
"INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
"Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
"SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
]
fixable = [
"I",
"F401",
"D",
"UP",
"ANN",
"B",
"C4",
"G",
"PIE",
"PT",
"RSE",
"SIM",
"RUF"
"I",
"F401",
"D",
"UP",
"ANN",
"B",
"C4",
"LOG",
"G",
"PIE",
"PT",
"RSE",
"SIM",
"PERF",
"FURB",
"RUF"
]
# ANN101 - missing-type-self
# ANN003 - missing-type-kwargs
# ANN101 - missing-type-self
# ANN102 - missing-type-cls
# D203 - one-blank-line-before-class
# D205 - blank-line-after-summary
# D206 - indent-with-spaces*
Expand All @@ -132,9 +142,10 @@ fixable = [
# E501 - line-too-long*
# W191 - tab-indentation*
# PGH003 - blanket-type-ignore
# S321 - suspicious-ftp-lib-usage
# *ignored for compatibility with formatter
ignore = [
"ANN101", "ANN003",
"ANN003", "ANN101", "ANN102",
"D203", "D205", "D206", "D213", "D300", "D400", "D415",
"E111", "E114", "E117", "E501",
"W191",
Expand All @@ -147,14 +158,36 @@ ignore = [
# ANN2 - missing-return-type
# ANN201 - Missing type annotation
# ANN102 - missing-type-cls
# ARG001 - unused-function-argument
# D100 - undocumented-public-module
# D102 - undocumented-public-class
# N805 - invalid-first-argument-name-for-method
# S101 - assert
# SLF001 - private-member-access
# B011 - assert-false
# RUF001 - ambiguous-unicode-character-string
"tests/*" = ["ANN001", "ANN102", "ANN2", "S101", "B011"]
# INP001 - implicit-namespace-package
# T201 - print
"tests/*" = [
"ANN001",
"ANN102",
"ANN2",
"ARG001",
"D100",
"D102",
"S101",
"SLF001",
"B011",
"INP001"
]
"src/variation/schemas/*" = ["ANN001", "ANN201", "N805", "S101"]
"codebuild/*" = ["T201"]
"codebuild/*" = ["T201", "INP001"]

[tool.ruff.lint.flake8-bugbear]
# Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`.
extend-immutable-calls = ["fastapi.Query"]

[tool.ruff.lint.flake8-annotations]
mypy-init-return = true

[tool.ruff.format]
docstring-code-format = true
1 change: 1 addition & 0 deletions src/variation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The Variation Normalization package."""

import logging
from os import environ

Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Classifier package level import."""

from .amplification_classifier import AmplificationClassifier
from .cdna_deletion_classifier import CdnaDeletionClassifier
from .cdna_delins_classifier import CdnaDelInsClassifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/amplification_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Amplification Classifier"""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/cdna_deletion_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Cdna Deletion Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/cdna_delins_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Cdna DelIns Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/cdna_insertion_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Cdna insertion Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the cDNA Reference Agree Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/cdna_substitution_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Cdna Substitution Classifier."""

from typing import List, Optional

from variation.classifiers.classifier import Classifier
Expand Down
3 changes: 2 additions & 1 deletion src/variation/classifiers/classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for Classification methods."""

from abc import ABC, abstractmethod
from typing import List, Optional

Expand Down Expand Up @@ -39,6 +40,6 @@ def can_classify(self, tokens: List[Token]) -> bool:

for candidate in self.exact_match_candidates():
if token_types == candidate:
exact_matches.append(candidate)
exact_matches.append(candidate) # noqa: PERF401

return len(exact_matches) == 1
1 change: 1 addition & 0 deletions src/variation/classifiers/genomic_deletion_ambiguous.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Genomic Deletion Ambiguous Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/genomic_deletion_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Genomic Deletion Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/genomic_delins_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Genomic DelIns Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/genomic_duplication_ambiguous.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Genomic Duplication Ambiguous Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Genomic Duplication Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/genomic_insertion_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Genomic Insertion Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Genomic Reference Agree Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Genomic Substitution Classifier."""

from typing import List, Optional

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/gnomad_vcf_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the gnomAD VCF Classifier"""

from typing import List, Optional, Union

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/hgvs_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the HGVS Classifier."""

from re import Match, Pattern
from typing import Dict, List, Optional

Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/protein_deletion_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Protein Deletion Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/protein_delins_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Protein DelIns Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/protein_insertion_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Protein Insertion Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/protein_reference_agree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Reference Agree Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classifiers/protein_stop_gain_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Protein Stop Gain Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module for the Protein Substitution Classifier."""

from typing import List

from variation.classifiers.classifier import Classifier
Expand Down
1 change: 1 addition & 0 deletions src/variation/classify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for classification."""

from typing import ClassVar, List, Optional

from variation.classifiers import (
Expand Down
7 changes: 4 additions & 3 deletions src/variation/gnomad_vcf_to_protein_variation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for translating VCF-like to protein VRS Allele representation"""

import datetime
from typing import List, Optional, Tuple

Expand Down Expand Up @@ -67,7 +68,7 @@ def _trim_prefix_or_suffix(
len_aa_alt = len(aa_alt)

# Trim prefixes
range_len = len_aa_ref if len_aa_ref < len_aa_alt else len_aa_alt
range_len = min(len_aa_alt, len_aa_ref)
aa_match = _get_char_match_count(
range_len, aa_ref, aa_alt, trim_prefix=trim_prefix
)
Expand Down Expand Up @@ -271,8 +272,8 @@ def _get_genomic_pos_range(
for the original position change
"""
# Get cDNA reading frame
start_reading_frame = self.mane_transcript._get_reading_frame(c_start_pos + 1)
end_reading_frame = self.mane_transcript._get_reading_frame(c_end_pos)
start_reading_frame = self.mane_transcript._get_reading_frame(c_start_pos + 1) # noqa: SLF001
end_reading_frame = self.mane_transcript._get_reading_frame(c_end_pos) # noqa: SLF001

# Get genomic position range change
# This ensures that there 3 nucleotides needed for codon
Expand Down
1 change: 1 addition & 0 deletions src/variation/hgvs_dup_del_mode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for hgvs_dup_del_mode in normalize endpoint."""

from typing import Dict, List, Optional, Union

from cool_seq_tool.handlers import SeqRepoAccess
Expand Down
Loading

0 comments on commit 59af2a0

Please sign in to comment.