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

Setup initial ruff #496

Merged
merged 11 commits into from
Aug 31, 2024
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ repos:
hooks:
- id: black

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

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Upcoming

# v0.5.2

### Fixes

* Fixed import error when using the CLI with `--config dandi`. [#494](https://github.com/NeurodataWithoutBorders/nwbinspector/issues/494)
* Removed unused imports throughout package. [#496](https://github.com/NeurodataWithoutBorders/nwbinspector/issues/496)



# v0.5.0

### Deprecation (API)
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ extend-exclude = '''
)/
'''



[tool.ruff]
exclude = ["docs/*"]

[tool.ruff.lint]
select = ["F401", "I002"] # TODO: eventually, expand to other 'I', 'D', and other 'F' linting
fixable = ["ALL"]

[tool.ruff.lint.per-file-ignores]
"src/nwbinspector/__init__.py" = ["I"] # Must maintain explicit order for imports for check registration
"src/nwbinspector/utils/__init__.py" = ["F401", "I"] # Several items planned for long-term deprecation

# Temporarily keeping all exposure below for back-compatibility
# Deprecation scheduled for 9/15/2024
"src/nwbinspector/nwbinspector/__init__.py" = ["F401", "I"]
"src/nwbinspector/inspector_tools/__init__.py" = ["F401", "I"]
"src/nwbinspector/version/__init__.py" = ["F401", "I"]
"src/nwbinspector/register_checks/__init__.py" = ["F401", "I"]


[tool.codespell]
skip = '.git*,*.pdf,*.css'
check-hidden = true
Expand Down
1 change: 1 addition & 0 deletions src/nwbinspector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Importance",
"Severity",
"InspectorMessage",
"validate_config",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caught one more

"load_config",
"configure_checks",
"InspectorOutputJSONEncoder",
Expand Down
4 changes: 1 addition & 3 deletions src/nwbinspector/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import json
import jsonschema
from pathlib import Path
from enum import Enum
from typing import Optional, List
from types import FunctionType
from packaging.version import Version

import yaml

from . import available_checks
from ._registration import InspectorMessage, Importance
from ._registration import Importance
from nwbinspector.utils._utils import (
PathType,
)
Expand Down
3 changes: 0 additions & 3 deletions src/nwbinspector/_registration.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Primary decorator used on a check function to add it to the registry and automatically parse its output."""

from collections.abc import Iterable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And cleaned up many others (unused imports)

from functools import wraps
from enum import Enum
from dataclasses import dataclass
from typing import Optional

import h5py
Expand Down
7 changes: 0 additions & 7 deletions src/nwbinspector/_types.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
"""Primary decorator used on a check function to add it to the registry and automatically parse its output."""

from collections.abc import Iterable
from functools import wraps
from enum import Enum
from dataclasses import dataclass
from typing import Optional

import h5py
from pynwb import NWBFile
from pynwb.file import Subject
from pynwb.ecephys import Device, ElectrodeGroup


class Importance(Enum):
"""A definition of the valid importance levels for a given check function."""
Expand Down
Loading