Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
fix typing python 3.7 & add isort
Browse files Browse the repository at this point in the history
Signed-off-by: zethson <[email protected]>
  • Loading branch information
Zethson committed May 14, 2021
1 parent 471685f commit 0fd4e9a
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 32 deletions.
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
multi_line_output=3
include_trailing_comma=True
line_length=120
17 changes: 11 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ repos:
types: [python]
require_serial: true
exclude: templates
- id: reorder-python-imports
name: Reorder python imports
entry: reorder-python-imports
language: system
types: [python]
args: [--application-directories=src]
- id: trailing-whitespace
name: Trim Trailing Whitespace
entry: trailing-whitespace-fixer
Expand All @@ -53,3 +47,14 @@ repos:
hooks:
- id: prettier
exclude: templates
- repo: https://github.com/pycqa/isort
rev: 5.8.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
3 changes: 1 addition & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from rich import print

try:
from nox_poetry import Session
from nox_poetry import session
from nox_poetry import Session, session
except ImportError:
print("[bold red]Did not found nox-poetry installed in your current environment!")
print("[bold blue]Try installing it using [bold green]pip install nox-poetry [bold blue]! ")
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ seaborn = "^0.11.1"
pandas = "^1.2.4"
scipy = "^1.6.3"
scikit-learn = "^0.24.1"
typing-extensions = "^3.10.0"

[tool.poetry.dev-dependencies]
pytest = "^6.2.4"
Expand Down
4 changes: 1 addition & 3 deletions sc_toolbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
__email__ = "[email protected]"
__version__ = "0.6.0"

from sc_toolbox.api import plot
from sc_toolbox.api import calc
from sc_toolbox.api import util
from sc_toolbox.api import calc, plot, util
4 changes: 2 additions & 2 deletions sc_toolbox/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import click
import rich.logging
from rich import print
from rich import traceback
from rich import print, traceback

from sc_toolbox.cli.commands.create import ProjectCreator
from sc_toolbox.cli.commands.upgrade import UpgradeCommand

Expand Down
9 changes: 7 additions & 2 deletions sc_toolbox/api/calc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import os
from typing import List
from typing import Literal

try:
from typing import Literal
except ImportError:
from typing_extensions import Literal # type: ignore

from typing import Optional

import numpy as np
Expand Down Expand Up @@ -206,8 +211,8 @@ def remove_outliers(cords, eps: int = 1, min_samples: int = 2):
Pandas DataFrame of clusters
"""
from sklearn.cluster import DBSCAN
from natsort import natsorted
from sklearn.cluster import DBSCAN

clustering = DBSCAN(eps=eps, min_samples=min_samples).fit(cords)
cluster = clustering.labels_.astype("U")
Expand Down
6 changes: 1 addition & 5 deletions sc_toolbox/api/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from enum import Enum
from typing import Dict
from typing import List
from typing import Sequence
from typing import Tuple
from typing import Union
from typing import Dict, List, Sequence, Tuple, Union

import matplotlib.pyplot as plt
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion sc_toolbox/api/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def read_concatenate_to_adata(file_paths: List[str]) -> AnnData:
Returns:
Single AnnData object containing all concatenated files
"""
import anndata as ad
import gc

import anndata as ad
import scipy.sparse

for index, file_name in enumerate(file_paths):
Expand Down
4 changes: 2 additions & 2 deletions sc_toolbox/cli/commands/create.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import os
from dataclasses import asdict
from dataclasses import dataclass
from dataclasses import asdict, dataclass

from cookiecutter.main import cookiecutter

from sc_toolbox.cli.questionary import sc_toolbox_questionary

log = logging.getLogger(__name__)
Expand Down
13 changes: 5 additions & 8 deletions sc_toolbox/cli/commands/upgrade.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import json
import sys
from subprocess import check_call
from subprocess import PIPE
from subprocess import Popen
from urllib.error import HTTPError
from urllib.error import URLError
from urllib.request import Request
from urllib.request import urlopen
from subprocess import PIPE, Popen, check_call
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

import sc_toolbox
from pkg_resources import parse_version
from rich import print

import sc_toolbox
from sc_toolbox.cli.questionary import sc_toolbox_questionary


Expand Down
1 change: 1 addition & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test cases for the __main__ module."""
import pytest
from click.testing import CliRunner

from sc_toolbox import __main__


Expand Down

0 comments on commit 0fd4e9a

Please sign in to comment.