Skip to content

Commit

Permalink
style: swap out black for ruff-format
Browse files Browse the repository at this point in the history
ruff-format is a rust implementation of the black formatter that is 10x faster with 99.9% compatiblity. This commit swaps out black for the ruff-format as the pre-commit hook that checks formatting.
  • Loading branch information
kenibrewer authored Mar 2, 2024
1 parent 3505fd9 commit 46b03ab
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 10 deletions.
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.6"
hooks:
- id: black
language_version: python3.9
- id: ruff-format
exclude: tutorials/nbconverted/
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
Expand Down
1 change: 1 addition & 0 deletions pycytominer/cyto_utils/DeepProfiler_processing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utility function to load and process the output files of a DeepProfiler run.
"""

import os
import pathlib
import numpy as np
Expand Down
3 changes: 1 addition & 2 deletions pycytominer/cyto_utils/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,8 @@ def merge_single_cells(
self.image_df.merge(sc_df, on=self.merge_cols, how="right")
# pandas rename performance may be improved using copy=False, inplace=False
# reference: https://ryanlstevens.github.io/2022-05-06-pandasColumnRenaming/
.rename(self.linking_col_rename, axis="columns", copy=False, inplace=False)
.rename(
self.linking_col_rename, axis="columns", copy=False, inplace=False
).rename(
self.full_merge_suffix_rename, axis="columns", copy=False, inplace=False
)
)
Expand Down
4 changes: 2 additions & 2 deletions pycytominer/cyto_utils/single_cell_ingest_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def assert_linking_cols_complete(linking_cols="default", compartments="default")
# Confirm that every compartment has been specified in the linking_cols
unique_linking_cols = sorted(list(set(unique_linking_cols)))
diff_column = set(compartments).difference(unique_linking_cols)
assert unique_linking_cols == sorted(
compartments
assert (
unique_linking_cols == sorted(compartments)
), "All compartments must be specified in the linking_cols, {miss} is missing".format(
miss=diff_column
)
Expand Down
1 change: 1 addition & 0 deletions pycytominer/feature_select.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Select features to use in downstream analysis based on specified selection method
"""

from pycytominer.operations import (
correlation_threshold,
variance_threshold,
Expand Down
46 changes: 44 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,51 @@ version_files = [
"CITATION.cff"
]

[tool.black]
[tool.ruff]
target-version = "py38"
line-length = 88
target-version = ['py39']
fix = true
select = [
# flake8-2020
# "YTT",
# flake8-bandit
#"S",
# flake8-bugbear
# "B",
# flake8-builtins
# "A",
# flake8-comprehensions
# "C4",
# flake8-debugger
# "T10",
# flake8-simplify
# "SIM",
# isort
# "I",
# mccabe
# "C90",
# pycodestyle
# "E", "W",
# pyflakes
# "F",
# pygrep-hooks
# "PGH",
# pyupgrade
# "UP",
# ruff
# "RUF",
# tryceratops
# "TRY",
]
ignore = [
# LineTooLong
"E501",
# DoNotAssignLambda
"E731",
]

[tool.ruff.format]
preview = true

[tool.pytest.ini_options]
testpaths = "tests"
Expand Down
1 change: 1 addition & 0 deletions tests/test_cyto_utils/test_DeepProfiler_processing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This tests the output from a DeepProfiler run (May 2021)
"""

import os
import random
import pytest
Expand Down

0 comments on commit 46b03ab

Please sign in to comment.