Skip to content

Commit

Permalink
chore: update ruff pre-commit and rules (#522)
Browse files Browse the repository at this point in the history
* chore: update ruff pre-commit and rules

* refactor: to address None type and remove typeignore

---------

Co-authored-by: Daniel Suveges <daniel.suveges@protonmail.com>
  • Loading branch information
d0choa and DSuveges committed Mar 8, 2024
1 parent 8f91f3a commit af16331
Show file tree
Hide file tree
Showing 35 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ci:
autofix_commit_msg: "chore: pre-commit auto fixes [...]"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
rev: v0.3.0
hooks:
- id: ruff
args:
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ module = [
ignore_missing_imports = true


[tool.ruff]
[tool.ruff.lint]
select = [
"B002", # Python does not support the unary prefix increment
"B007", # Loop control variable {name} not used within loop body
"B014", # Exception handler with duplicate exception
"B023", # Function definition does not bind loop variable {name}
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
"B904", # Checks for raise statements in exception handlers that lack a from clause
"C", # complexity
"COM818", # Trailing comma on bare tuple prohibited
"D", # docstrings
Expand All @@ -180,7 +181,6 @@ select = [
"N804", # First argument of a class method should be named cls
"N805", # First argument of a method should be named self
"N815", # Variable {name} in class scope should not be mixedCase
"PGH001", # No builtin eval() allowed
"PGH004", # Use specific rule codes when using noqa
"PLC0414", # Useless import alias. Import alias does not rename original package.
"PLC", # pylint
Expand Down Expand Up @@ -219,7 +219,6 @@ select = [
"T20", # flake8-print
"TID251", # Banned imports
"TRY004", # Prefer TypeError exception for invalid type
"TRY200", # Use raise from to specify exception cause
"TRY302", # Remove exception handler; error is immediately re-raised
"UP", # pyupgrade
"W", # pycodestyle
Expand Down
1 change: 1 addition & 0 deletions tests/airflow/test_dag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Check for airflow import errors. Inspiration from https://garystafford.medium.com/devops-for-dataops-building-a-ci-cd-pipeline-for-apache-airflow-dags-975e4a622f83."""

from __future__ import annotations

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/common/test_session.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests GWAS Catalog study splitter."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit test configuration."""

from __future__ import annotations

from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_colocalisation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test colocalisation dataset."""

from __future__ import annotations

from gentropy.dataset.colocalisation import Colocalisation
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Dataset class."""

from __future__ import annotations

import pyspark.sql.functions as f
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_gene_index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests on LD index."""

from __future__ import annotations

from gentropy.dataset.gene_index import GeneIndex
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_intervals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests on LD index."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
5 changes: 3 additions & 2 deletions tests/gentropy/dataset/test_l2g.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests on L2G datasets."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down Expand Up @@ -167,8 +168,8 @@ def test_calculate_feature_missingness_rate(spark: SparkSession) -> None:
expected_missingness = {"distanceTssMean": 0.0, "distanceTssMinimum": 1.0}
observed_missingness = fm.calculate_feature_missingness_rate()
assert isinstance(observed_missingness, dict)
assert len(observed_missingness) == len(
fm.features_list # type: ignore
assert fm.features_list is not None and len(observed_missingness) == len(
fm.features_list
), "Missing features in the missingness rate dictionary."
assert (
observed_missingness == expected_missingness
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_ld_index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests on LD index."""

from __future__ import annotations

from gentropy.dataset.ld_index import LDIndex
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_study_index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test study index dataset."""

from __future__ import annotations

from gentropy.dataset.study_index import StudyIndex
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_study_locus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test study locus dataset."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_study_locus_overlap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test study locus overlap dataset."""

from __future__ import annotations

from gentropy.dataset.study_locus_overlap import StudyLocusOverlap
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_study_locus_overlaps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test colocalisation dataset."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_summary_statistics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test study index dataset."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_v2g.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests V2G dataset."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_variant_annotation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests variant annotation dataset."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/dataset/test_variant_index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests on variant index generation."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests GWAS Catalog study splitter."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/datasource/intervals/test_andersson.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Andersson Intervals."""

from __future__ import annotations

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/datasource/intervals/test_javierre.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test JavierreIntervals."""

from __future__ import annotations

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/datasource/intervals/test_jung.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Jung Intervals."""

from __future__ import annotations

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/datasource/intervals/test_thurman.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Thurman."""

from __future__ import annotations

import pytest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Open Targets L2G gold standards data source."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/datasource/open_targets/test_target.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Open Targets target data source."""

from __future__ import annotations

from gentropy.dataset.gene_index import GeneIndex
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/docs/test_applying_methods.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Testing applying methods docs."""

from typing import Any

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/docs/test_create_dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Testing creating dataset docs."""

from typing import Any

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/docs/test_creating_spark_session.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Testing creating spark session docs."""

from gentropy.common.session import Session

from docs.src_snippets.howto.python_api.a_creating_spark_session import (
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/docs/test_inspect_dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Testing inspecting dataset docs."""

from gentropy.dataset.summary_statistics import SummaryStatistics
from pyspark.sql.types import StructType

Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/method/test_window_based_clumping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test window-based clumping."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/step/test_clump_step.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test clump step."""

from __future__ import annotations

import tempfile
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the command-line interface (CLI)."""

from unittest.mock import patch

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/test_schemas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests on spark schemas."""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions tests/gentropy/test_spark_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests on helper spark functions."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any
Expand Down

0 comments on commit af16331

Please sign in to comment.