From 51b2b866de505c7da66dc84f5f0953fe235be734 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 10 Jul 2024 16:41:08 -0400 Subject: [PATCH 1/2] update configs --- .pre-commit-config.yaml | 2 +- pyproject.toml | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 723c54a..7c057a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,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 diff --git a/pyproject.toml b/pyproject.toml index 969be04..062b369 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ dynamic=["version"] [project.optional-dependencies] tests = ["pytest", "pytest-cov", "pytest-asyncio"] -dev = ["pre-commit", "pytest", "pytest-cov", "pytest-asyncio", "ruff==0.2.0"] +dev = ["pre-commit", "pytest", "pytest-cov", "pytest-asyncio", "ruff==0.5.0"] [project.urls] Homepage = "https://github.com/cancervariants/fusor" @@ -85,16 +85,22 @@ select = [ "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 = [ @@ -105,15 +111,19 @@ fixable = [ "ANN", "B", "C4", + "LOG", "G", "PIE", "PT", "RSE", "SIM", - "RUF" + "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* @@ -129,7 +139,7 @@ fixable = [ # 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", @@ -145,5 +155,10 @@ ignore = [ # S101 - assert # B011 - assert-false # N805 - invalid-first-argument-name-for-method -"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "B011"] +# INP001 - implicit-namespace-package +# SLF001 - private-member-access +"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "B011", "INP001", "SLF001"] "src/fusor/models.py" = ["ANN201", "N805", "ANN001", "ANN2", "ANN102"] + +[tool.ruff.format] +docstring-code-format = true From 40d372d19ff95cf39340e7673e792941b9190b12 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 10 Jul 2024 16:42:02 -0400 Subject: [PATCH 2/2] ruff format --- src/fusor/__init__.py | 1 + src/fusor/examples/__init__.py | 1 + src/fusor/fusor.py | 1 + src/fusor/models.py | 17 +++++++++-------- src/fusor/nomenclature.py | 1 + src/fusor/tools.py | 1 + src/fusor/version.py | 1 + tests/conftest.py | 1 + tests/test_fusor.py | 7 ++++--- tests/test_models.py | 1 + tests/test_nomenclature.py | 1 + tests/test_tools.py | 1 + 12 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/fusor/__init__.py b/src/fusor/__init__.py index cb5e8b6..c2d0020 100644 --- a/src/fusor/__init__.py +++ b/src/fusor/__init__.py @@ -1,4 +1,5 @@ """Provide computable object representation and validation for gene fusions""" + from fusor.fusor import FUSOR from .version import __version__ diff --git a/src/fusor/examples/__init__.py b/src/fusor/examples/__init__.py index 8cecbc5..9e44773 100644 --- a/src/fusor/examples/__init__.py +++ b/src/fusor/examples/__init__.py @@ -1,4 +1,5 @@ """Provide programmatic access to example objects.""" + import json from pathlib import Path diff --git a/src/fusor/fusor.py b/src/fusor/fusor.py index 017b79a..02932da 100644 --- a/src/fusor/fusor.py +++ b/src/fusor/fusor.py @@ -1,4 +1,5 @@ """Module for modifying fusion objects.""" + import logging import re from urllib.parse import quote diff --git a/src/fusor/models.py b/src/fusor/models.py index 9e14af2..124ee79 100644 --- a/src/fusor/models.py +++ b/src/fusor/models.py @@ -1,4 +1,5 @@ """Model for fusion class""" + from abc import ABC from enum import Enum from typing import Any, Literal @@ -120,9 +121,9 @@ class BaseStructuralElement(ABC, BaseModel): class TranscriptSegmentElement(BaseStructuralElement): """Define TranscriptSegment class""" - type: Literal[ + type: Literal[FUSORTypes.TRANSCRIPT_SEGMENT_ELEMENT] = ( FUSORTypes.TRANSCRIPT_SEGMENT_ELEMENT - ] = FUSORTypes.TRANSCRIPT_SEGMENT_ELEMENT + ) transcript: CURIE exon_start: StrictInt | None = None exon_start_offset: StrictInt | None = 0 @@ -212,9 +213,9 @@ def check_exons(cls, values): class LinkerElement(BaseStructuralElement, extra="forbid"): """Define Linker class (linker sequence)""" - type: Literal[ + type: Literal[FUSORTypes.LINKER_SEQUENCE_ELEMENT] = ( FUSORTypes.LINKER_SEQUENCE_ELEMENT - ] = FUSORTypes.LINKER_SEQUENCE_ELEMENT + ) linker_sequence: SequenceDescriptor @field_validator("linker_sequence", mode="before") @@ -260,9 +261,9 @@ class TemplatedSequenceElement(BaseStructuralElement): product. """ - type: Literal[ + type: Literal[FUSORTypes.TEMPLATED_SEQUENCE_ELEMENT] = ( FUSORTypes.TEMPLATED_SEQUENCE_ELEMENT - ] = FUSORTypes.TEMPLATED_SEQUENCE_ELEMENT + ) region: LocationDescriptor strand: Strand @@ -340,9 +341,9 @@ class MultiplePossibleGenesElement(BaseStructuralElement): MultiplePossibleGenesElement. """ - type: Literal[ + type: Literal[FUSORTypes.MULTIPLE_POSSIBLE_GENES_ELEMENT] = ( FUSORTypes.MULTIPLE_POSSIBLE_GENES_ELEMENT - ] = FUSORTypes.MULTIPLE_POSSIBLE_GENES_ELEMENT + ) model_config = ConfigDict( json_schema_extra={"example": {"type": "MultiplePossibleGenesElement"}}, diff --git a/src/fusor/nomenclature.py b/src/fusor/nomenclature.py index 4ea0cc5..ee14593 100644 --- a/src/fusor/nomenclature.py +++ b/src/fusor/nomenclature.py @@ -1,4 +1,5 @@ """Provide helper methods for fusion nomenclature generation.""" + from biocommons.seqrepo.seqrepo import SeqRepo from ga4gh.vrsatile.pydantic.vrs_models import SequenceLocation diff --git a/src/fusor/tools.py b/src/fusor/tools.py index 5b3df24..0f14455 100644 --- a/src/fusor/tools.py +++ b/src/fusor/tools.py @@ -1,4 +1,5 @@ """Provide miscellaneous tools for fusion modeling.""" + import logging from biocommons.seqrepo.seqrepo import SeqRepo diff --git a/src/fusor/version.py b/src/fusor/version.py index f855f0a..e825a12 100644 --- a/src/fusor/version.py +++ b/src/fusor/version.py @@ -1,2 +1,3 @@ """Define library version.""" + __version__ = "0.1.0" diff --git a/tests/conftest.py b/tests/conftest.py index 62ca388..a7dfcee 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Module containing methods and fixtures used throughout tests.""" + import logging import pytest diff --git a/tests/test_fusor.py b/tests/test_fusor.py index c4e113d..1039316 100644 --- a/tests/test_fusor.py +++ b/tests/test_fusor.py @@ -1,4 +1,5 @@ """Module for testing the FUSOR class.""" + import copy import pytest @@ -817,9 +818,9 @@ def test_templated_sequence_element( assert tsg.model_dump() == templated_sequence_element.model_dump() expected = copy.deepcopy(templated_sequence_element.model_dump()) - expected["region"]["location"][ - "sequence_id" - ] = "ga4gh:SQ.Ya6Rs7DHhDeg7YaOSg1EoNi3U_nQ9SvO" + expected["region"]["location"]["sequence_id"] = ( + "ga4gh:SQ.Ya6Rs7DHhDeg7YaOSg1EoNi3U_nQ9SvO" + ) expected["region"]["location_id"] = "ga4gh:VSL.bL1N-PQfp4dGlEz6PEd34fGxdxo82Zkb" tsg = fusor_instance.templated_sequence_element( 100, diff --git a/tests/test_models.py b/tests/test_models.py index 088a0cb..c77c031 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,4 +1,5 @@ """Module for testing the fusion model.""" + import copy import pytest diff --git a/tests/test_nomenclature.py b/tests/test_nomenclature.py index 8cc2e8a..90a223e 100644 --- a/tests/test_nomenclature.py +++ b/tests/test_nomenclature.py @@ -1,4 +1,5 @@ """Test nomenclature generation.""" + import pytest from fusor.models import AssayedFusion, CategoricalFusion, TranscriptSegmentElement diff --git a/tests/test_tools.py b/tests/test_tools.py index fbc69e4..ffd681a 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1,4 +1,5 @@ """Test FUSOR tools.""" + import pytest from fusor.exceptions import IDTranslationException