Skip to content

Commit

Permalink
chore: use ruff format, add typos (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored Mar 4, 2024
1 parent 02cdd8e commit 467c66c
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 141 deletions.
43 changes: 10 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,23 @@ ci:
autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]"
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"

default_install_hook_types: [pre-commit, commit-msg]

repos:
# - repo: https://github.com/compilerla/conventional-pre-commit
# rev: v2.3.0
# hooks:
# - id: conventional-pre-commit
# stages: [commit-msg]
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.16
hooks:
- id: validate-pyproject

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
- repo: https://github.com/crate-ci/typos
rev: v1.19.0
hooks:
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace
- id: typos

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.3.0
hooks:
- id: ruff
args: [--fix]

- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.16
hooks:
- id: validate-pyproject
args: [--fix, --unsafe-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
Expand All @@ -46,12 +32,3 @@ repos:
- types-lxml
- ome-types
- pydantic


- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
exclude: CHANGELOG.md
args:
- "-L=nd2,nd,pevents"
30 changes: 18 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ test = [
]
dev = [
"aicsimageio",
"black",
"dask[array]",
"imagecodecs",
"ipython",
Expand Down Expand Up @@ -72,15 +71,20 @@ source = "vcs"
only-include = ["src"]
sources = ["src"]

# https://beta.ruff.rs/docs/rules/
# https://docs.astral.sh/ruff/rules
[tool.ruff]
line-length = 88
target-version = "py38"
src = ["src/nd2", "tests"]

[tool.ruff.lint]
pydocstyle = { convention = "numpy" }
select = [
"E", # style errors
"W", # style warnings
"F", # flakes
"D", # pydocstyle
"D417", # Missing argument descriptions in Docstrings
"I", # isort
"UP", # pyupgrade
"S", # bandit
Expand All @@ -93,23 +97,19 @@ select = [
"TCH", # flake8-type-checking
]
ignore = [
"D100", # Missing docstring in public module
"D107", # Missing docstring in __init__
"D203", # 1 blank line required before class docstring
"D212", # Multi-line docstring summary should start at the first line
"D213", # Multi-line docstring summary should start at the second line
"D400", # First line should end with a period
"D401", # First line should be in imperative mood
"D413", # Missing blank line after last section
"D416", # Section name should end with a colon
"C901", # Function is too complex
"D100", # Missing docstring in public module
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"src/nd2/structures.py" = ["D101", "D105"] # Fix someday
"tests/*.py" = ["D", "S"]
"scripts/*.py" = ["D", "S"]

# https://docs.astral.sh/ruff/formatter/
[tool.ruff.format]
docstring-code-format = true

# https://docs.pytest.org/en/6.2.x/customize.html
[tool.pytest.ini_options]
minversion = "6.0"
Expand Down Expand Up @@ -165,3 +165,9 @@ ignore = [
"tests/**/*",
"src/nd2/_version.py",
]

[tool.typos.default]
extend-ignore-identifiers-re = ["nd2?.*", "ND2?.*"]

[tool.typos.files]
extend-exclude = ["*.json", "**/_sdk_types.py"]
4 changes: 3 additions & 1 deletion src/nd2/_parse/_clx_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def _node_name_value(
value = dict(node.attrib) if include_attrs else {}
for i, child in enumerate(node):
cname, cval = _node_name_value(
child, strip_prefix, include_attrs # type: ignore
child, # type: ignore
strip_prefix,
include_attrs,
)
# NOTE: "no_name" is the standard name for a list-type node
# "BinaryItem" is a special case found in the BinaryMetadata_v1 tag...
Expand Down
2 changes: 1 addition & 1 deletion src/nd2/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def convert_dict_of_lists_to_records(
Examples
--------
>>> lists = {'a': [1, 4, float('nan')], 'b': [float('nan'), 5, 8], 'c': [3, 6, 9]}
>>> lists = {"a": [1, 4, float("nan")], "b": [float("nan"), 5, 8], "c": [3, 6, 9]}
>>> convert_dict_of_lists_to_records(records)
[
{"a": 1, "c": 3},
Expand Down
Loading

0 comments on commit 467c66c

Please sign in to comment.