Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use ruff format, add typos #213

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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