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

style: update ruff configs #578

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The variation-normalization repo depends on VRS models, and therefore each varia
| variation-normalization branch | variation-normalizer version | gene-normalizer version | VRS version |
| ---- | --- | ---- | --- |
| [main](https://github.com/cancervariants/variation-normalization/tree/main) | 0.6.X | 0.1.X | [1.X.X](https://github.com/ga4gh/vrs) |
| [staging](https://github.com/cancervariants/variation-normalization/tree/staging) | 0.8.X | 0.3.X | [2.0-alpha](https://github.com/ga4gh/vrs/tree/2.0-alpha) |
| [staging](https://github.com/cancervariants/variation-normalization/tree/staging) | >=0.8.X | >=0.3.X | [2.0-alpha](https://github.com/ga4gh/vrs/tree/2.0-alpha) |

## About

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
134 changes: 84 additions & 50 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.8"
description = "VICC normalization routine for variations"
Expand All @@ -39,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 All @@ -49,7 +50,7 @@ Source = "https://github.com/cancervariants/variation-normalization"
"Bug Tracker" = "https://github.com/cancervariants/variation-normalization/issues"

[build-system]
requires = ["setuptools>=61.0"]
requires = ["setuptools>=64"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
Expand All @@ -72,52 +73,62 @@ branch = true
[tool.ruff]
src = ["src"]

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
[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
"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
]

lint.fixable = [
"I",
"F401",
"D",
"UP",
"ANN",
"B",
"C4",
"G",
"PIE",
"PT",
"RSE",
"SIM",
"RUF"
fixable = [
"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 @@ -131,9 +142,10 @@ lint.fixable = [
# E501 - line-too-long*
# W191 - tab-indentation*
# PGH003 - blanket-type-ignore
# S321 - suspicious-ftp-lib-usage
# *ignored for compatibility with formatter
lint.ignore = [
"ANN101", "ANN003",
ignore = [
"ANN003", "ANN101", "ANN102",
"D203", "D205", "D206", "D213", "D300", "D400", "D415",
"E111", "E114", "E117", "E501",
"W191",
Expand All @@ -146,14 +158,36 @@ lint.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
Loading
Loading