Skip to content

Commit

Permalink
Fix isort pre-commit hooks (#61)
Browse files Browse the repository at this point in the history
* Exclude import sorting in `ruff`

As of now, `ruff` does not allow custom sorting and ordering of imports.
See astral-sh/ruff#2419.

* Run pre-commit hooks

Apply `isort` changes.
  • Loading branch information
WeilerP authored Mar 15, 2023
1 parent 8f212f7 commit 3b5dd81
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ repos:
rev: 1.13.0
hooks:
- id: blacken-docs
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use_parentheses = true
known_num = "networkx,numpy,pandas,scipy,sklearn,statmodels"
known_plot = "matplotlib,mpl_toolkits,seaborn"
known_bio = "anndata"
sections = "FUTURE,STDLIB,THIRDPARTY,NUM,PLOT,BIO,FIRSTPARTY,LOCALFOLDER"
known_r = "rpy2"
known_firstparty = "tradeseq"
sections = "FUTURE,STDLIB,THIRDPARTY,NUM,PLOT,R,BIO,FIRSTPARTY,LOCALFOLDER"
no_lines_before = "LOCALFOLDER"
balanced_wrapping = true
length_sort = "0"
Expand All @@ -43,7 +45,6 @@ select = [
"F", # Errors detected by Pyflakes
"E", # Error detected by Pycodestyle
"W", # Warning detected by Pycodestyle
"I", # isort
"D", # pydocstyle
"B", # flake8-bugbear
"TID", # flake8-tidy-imports
Expand Down Expand Up @@ -89,10 +90,9 @@ ignore = [
]

[tool.ruff.per-file-ignores]
"docs/*" = ["I", "BLE001"]
"docs/*" = ["BLE001"]
"tests/*" = ["D"]
"*/__init__.py" = ["F401"]
"scvelo/__init__.py" = ["I"]

[tool.jupytext]
formats = "ipynb,md"
Expand Down
6 changes: 4 additions & 2 deletions tests/core/test_base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from typing import Optional

import hypothesis.strategies as st
import numpy as np
from anndata import AnnData
from hypothesis.extra.numpy import arrays

import numpy as np
from scipy.sparse import csr_matrix

from anndata import AnnData

from tradeseq.gam import GAM

MAX_INT_VALUE = 100
Expand Down
1 change: 1 addition & 0 deletions tests/core/tradeseq_r.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

import rpy2.robjects as ro
from rpy2.robjects import default_converter, numpy2ri
from rpy2.robjects.conversion import localconverter
Expand Down
3 changes: 2 additions & 1 deletion tests/de_tests/test_association.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Literal

import numpy as np
from hypothesis import given, settings
from hypothesis import strategies as st

import numpy as np

from tests.core.test_base import get_gam
from tradeseq.de_tests._association_test import AssociationTest
from tradeseq.gam import GAM
Expand Down
3 changes: 2 additions & 1 deletion tests/de_tests/test_diff_end.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from hypothesis import given, settings
from hypothesis import strategies as st

import numpy as np

from tests.core.test_base import get_gam
from tradeseq.de_tests._diff_end_test import DiffEndTest
from tradeseq.gam import GAM
Expand Down
3 changes: 2 additions & 1 deletion tests/de_tests/test_pattern.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from hypothesis import given, settings
from hypothesis import strategies as st

import numpy as np

from tests.core.test_base import get_gam
from tradeseq.de_tests._pattern_test import PatternTest
from tradeseq.gam import GAM
Expand Down
3 changes: 2 additions & 1 deletion tests/de_tests/test_start_vs_end.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from hypothesis import given, settings
from hypothesis import strategies as st

import numpy as np

from tests.core.test_base import get_gam
from tradeseq.de_tests._start_vs_end_test import StartVsEndTest
from tradeseq.gam import GAM
Expand Down
8 changes: 5 additions & 3 deletions tests/gam/test_fit.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import anndata as ad
import numpy as np
from hypothesis import given, settings
from hypothesis import strategies as st

import numpy as np

import anndata as ad

from tests.core.test_base import get_gam
from tests.core.tradeseq_r import TradeseqR
from tradeseq.gam._gam import GAM, _calculate_offset
from tradeseq.gam._gam import _calculate_offset, GAM


class TestGAMFitting:
Expand Down
5 changes: 3 additions & 2 deletions tests/gam/test_getters.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import numpy as np
import pytest
from hypothesis import assume, given, settings
from hypothesis import strategies as st
from hypothesis.extra.numpy import arrays

from tests.core.test_base import MAX_INT_VALUE, get_gam
import numpy as np

from tests.core.test_base import get_gam, MAX_INT_VALUE
from tradeseq.gam._gam import GAM


Expand Down
8 changes: 5 additions & 3 deletions tradeseq/_backend/_base.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
from abc import ABC, abstractmethod
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Literal,
Optional,
Tuple,
Type,
TYPE_CHECKING,
Union,
)

from packaging.version import LegacyVersion, parse, Version

import pandas as pd

import rpy2.robjects as ro
from packaging.version import LegacyVersion, Version, parse
from rpy2.rinterface_lib.embedded import RRuntimeError
from rpy2.robjects import pandas2ri
from rpy2.robjects.conversion import localconverter
from rpy2.robjects.packages import InstalledSTPackage, PackageNotInstalledError, importr
from rpy2.robjects.packages import importr, InstalledSTPackage, PackageNotInstalledError

__all__ = ("TradeSeqTest", "register")

Expand Down
6 changes: 4 additions & 2 deletions tradeseq/_backend/_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from abc import ABC
from typing import Any, Literal, Optional, Sequence

from packaging.version import parse

import pandas as pd

import rpy2.robjects as ro
from packaging.version import parse

from tradeseq._backend._base import TradeSeqTest, _load_library, register
from tradeseq._backend._base import _load_library, register, TradeSeqTest


# TODO: Add docstrings
Expand Down
10 changes: 6 additions & 4 deletions tradeseq/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
from abc import ABC, abstractmethod
from contextlib import redirect_stderr
from io import StringIO
from typing import TYPE_CHECKING, Any, Literal, Optional, Sequence, Sized, Tuple, Union
from typing import Any, Literal, Optional, Sequence, Sized, Tuple, TYPE_CHECKING, Union

import numpy as np
import pandas as pd
from scipy.sparse import issparse

import rpy2.robjects as ro
from anndata import AnnData
from rpy2.rinterface_lib.embedded import RRuntimeError
from rpy2.robjects import numpy2ri, pandas2ri
from rpy2.robjects.conversion import localconverter
from rpy2.robjects.packages import importr
from scipy.sparse import issparse

from tradeseq._backend._base import TradeSeqTest, _load_library
from anndata import AnnData

from tradeseq._backend._base import _load_library, TradeSeqTest

_PARALLEL = importr("BiocParallel")

Expand Down
1 change: 1 addition & 0 deletions tradeseq/gam/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pandas as pd

import rpy2.robjects as ro
from rpy2.robjects import default_converter, numpy2ri, pandas2ri
from rpy2.robjects.conversion import localconverter
Expand Down
9 changes: 6 additions & 3 deletions tradeseq/gam/_gam.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import warnings
from typing import List, Optional, Tuple, Union

import matplotlib.pyplot as plt
from conorm import tmm_norm_factors

import numpy as np
import pandas as pd
from scipy.sparse import issparse

import matplotlib.pyplot as plt
import seaborn as sns

from anndata import AnnData
from conorm import tmm_norm_factors
from scipy.sparse import issparse

from tradeseq.gam import _backend

Expand Down

0 comments on commit 3b5dd81

Please sign in to comment.