Skip to content

Commit 67dca89

Browse files
CodyCBakerPhDpre-commit-ci[bot]bendichter
authored
More ruff (isort) (#497)
* more ruff * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add preferred config --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ben Dichter <[email protected]>
1 parent adf6fe3 commit 67dca89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+224
-220
lines changed

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extend-exclude = '''
2727
exclude = ["docs/*"]
2828

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

3333
[tool.ruff.lint.per-file-ignores]
@@ -41,6 +41,11 @@ fixable = ["ALL"]
4141
"src/nwbinspector/version/__init__.py" = ["F401", "I"]
4242
"src/nwbinspector/register_checks/__init__.py" = ["F401", "I"]
4343

44+
[tool.ruff.lint.isort]
45+
relative-imports-order = "closest-to-furthest"
46+
known-first-party = ["nwbinspector"]
47+
48+
4449

4550
[tool.codespell]
4651
skip = '.git*,*.pdf,*.css'

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from setuptools import setup, find_packages
21
from pathlib import Path
32
from shutil import copy
43

4+
from setuptools import find_packages, setup
5+
56
root = Path(__file__).parent
67
with open(root / "README.md", "r") as f:
78
long_description = f.read()

src/nwbinspector/_configuration.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
"""Primary functions for inspecting NWBFiles."""
22

33
import json
4-
import jsonschema
54
from pathlib import Path
6-
from typing import Optional, List
75
from types import FunctionType
6+
from typing import List, Optional
87

8+
import jsonschema
99
import yaml
1010

11-
from . import available_checks
12-
from ._registration import Importance
1311
from nwbinspector.utils._utils import (
1412
PathType,
1513
)
1614

15+
from . import available_checks
16+
from ._registration import Importance
17+
1718
INTERNAL_CONFIGS = dict(dandi=Path(__file__).parent / "internal_configs" / "dandi.inspector_config.yaml")
1819

1920

src/nwbinspector/_formatting.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
"""Internally used tools specifically for rendering more human-readable output from collected check results."""
22

3-
import os
43
import json
4+
import os
55
import sys
6-
from typing import Dict, List, Optional, Union
7-
from pathlib import Path
8-
from enum import Enum
6+
from collections import defaultdict
97
from datetime import datetime
8+
from enum import Enum
9+
from pathlib import Path
1010
from platform import platform
11-
from collections import defaultdict
11+
from typing import Dict, List, Optional, Union
1212

1313
import numpy as np
1414

15-
from ._types import InspectorMessage, Importance
1615
from ._organization import organize_messages
17-
from .utils import get_package_version, FilePathType
16+
from ._types import Importance, InspectorMessage
17+
from .utils import FilePathType, get_package_version
1818

1919

2020
class InspectorOutputJSONEncoder(json.JSONEncoder):

src/nwbinspector/_inspection.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
"""Primary functions for inspecting NWBFiles."""
22

3-
import re
43
import importlib
4+
import re
55
import traceback
6-
from pathlib import Path
7-
from typing import Union, Optional, List, Iterable
6+
from collections import defaultdict
87
from concurrent.futures import ProcessPoolExecutor, as_completed
8+
from pathlib import Path
9+
from typing import Iterable, List, Optional, Union
910
from warnings import filterwarnings, warn
10-
from collections import defaultdict
11-
from packaging.version import Version
1211

1312
import pynwb
14-
from tqdm import tqdm
1513
from natsort import natsorted
14+
from packaging.version import Version
15+
from tqdm import tqdm
1616

1717
from . import available_checks, configure_checks
18-
from ._registration import InspectorMessage, Importance
18+
from ._registration import Importance, InspectorMessage
1919
from .tools import get_s3_urls_and_dandi_paths
2020
from .utils import (
2121
FilePathType,
22-
PathType,
2322
OptionalListOfStrings,
24-
robust_s3_read,
23+
PathType,
2524
calculate_number_of_cpu,
2625
get_package_version,
26+
robust_s3_read,
2727
)
2828

2929

src/nwbinspector/_inspection_cli.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
"""Primary functions for inspecting NWBFiles."""
22

3+
import json
34
import os
45
import re
5-
import json
66
from pathlib import Path
77
from typing import Optional
88
from warnings import warn
99

1010
import click
1111

12-
from ._formatting import _get_report_header, InspectorOutputJSONEncoder
13-
from . import Importance, inspect_all, format_messages, print_to_console, save_report, __version__, load_config
12+
from . import (
13+
Importance,
14+
__version__,
15+
format_messages,
16+
inspect_all,
17+
load_config,
18+
print_to_console,
19+
save_report,
20+
)
21+
from ._formatting import InspectorOutputJSONEncoder, _get_report_header
1422
from .utils import strtobool
1523

1624

src/nwbinspector/_organization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Internally used tools specifically for rendering more human-readable output from collected check results."""
22

3-
from typing import List, Optional
43
from enum import Enum
4+
from typing import List, Optional
55

66
from natsort import natsorted
77

src/nwbinspector/_registration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55

66
import h5py
77
from pynwb import NWBFile
8-
from pynwb.file import Subject
98
from pynwb.ecephys import Device, ElectrodeGroup
9+
from pynwb.file import Subject
1010

11-
from ._types import Importance, Severity, InspectorMessage
12-
11+
from ._types import Importance, InspectorMessage, Severity
1312

1413
available_checks = list()
1514

src/nwbinspector/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Primary decorator used on a check function to add it to the registry and automatically parse its output."""
22

3-
from enum import Enum
43
from dataclasses import dataclass
4+
from enum import Enum
55
from typing import Optional
66

77

src/nwbinspector/checks/__init__.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1+
from ._behavior import (
2+
check_compass_direction_unit,
3+
check_spatial_series_degrees_magnitude,
4+
check_spatial_series_dims,
5+
check_spatial_series_radians_magnitude,
6+
)
17
from ._ecephys import (
2-
check_negative_spike_times,
38
check_electrical_series_dims,
49
check_electrical_series_reference_electrodes_table,
10+
check_negative_spike_times,
511
check_spike_times_not_in_unobserved_interval,
612
)
713
from ._general import (
814
check_description,
915
check_name_slashes,
1016
)
17+
from ._icephys import (
18+
check_intracellular_electrode_cell_id_exists,
19+
)
1120
from ._image_series import (
1221
check_image_series_data_size,
1322
check_image_series_external_file_relative,
1423
check_image_series_external_file_valid,
1524
)
1625
from ._images import (
17-
check_order_of_images_unique,
18-
check_order_of_images_len,
1926
check_index_series_points_to_image,
27+
check_order_of_images_len,
28+
check_order_of_images_unique,
2029
)
2130
from ._nwb_containers import (
2231
check_empty_string_for_optional_attribute,
23-
check_small_dataset_compression,
2432
check_large_dataset_compression,
33+
check_small_dataset_compression,
2534
)
2635
from ._nwbfile_metadata import (
27-
check_keywords,
36+
check_doi_publications,
37+
check_experiment_description,
38+
check_experimenter_exists,
39+
check_experimenter_form,
2840
check_institution,
41+
check_keywords,
42+
check_processing_module_name,
43+
check_session_start_time_future_date,
44+
check_session_start_time_old_date,
2945
check_subject_age,
30-
check_subject_sex,
3146
check_subject_exists,
32-
check_doi_publications,
33-
check_experimenter_form,
34-
check_experimenter_exists,
35-
check_experiment_description,
3647
check_subject_id_exists,
48+
check_subject_proper_age_range,
49+
check_subject_sex,
3750
check_subject_species_exists,
3851
check_subject_species_form,
39-
check_subject_proper_age_range,
40-
check_session_start_time_future_date,
41-
check_processing_module_name,
42-
check_session_start_time_old_date,
4352
)
4453
from ._ogen import (
4554
check_optogenetic_stimulus_site_has_optogenetic_series,
4655
)
4756
from ._ophys import (
57+
check_emission_lambda_in_nm,
4858
check_excitation_lambda_in_nm,
4959
check_plane_segmentation_image_mask_shape_against_ref_images,
5060
check_roi_response_series_dims,
51-
check_emission_lambda_in_nm,
5261
check_roi_response_series_link_to_plane_segmentation,
5362
)
5463
from ._tables import (
55-
check_single_row,
56-
check_ids_unique,
57-
check_empty_table,
5864
check_col_not_nan,
5965
check_column_binary_capability,
6066
check_dynamic_table_region_data_validity,
67+
check_empty_table,
68+
check_ids_unique,
69+
check_single_row,
70+
check_table_time_columns_are_not_negative,
71+
check_table_values_for_dict,
6172
check_time_interval_time_columns,
6273
check_time_intervals_stop_after_start,
63-
check_table_values_for_dict,
64-
check_table_time_columns_are_not_negative,
6574
)
6675
from ._time_series import (
67-
check_resolution,
76+
check_data_orientation,
6877
check_missing_unit,
78+
check_rate_is_not_zero,
6979
check_regular_timestamps,
80+
check_resolution,
81+
check_timestamp_of_the_first_sample_is_not_negative,
7082
check_timestamps_ascending,
71-
check_data_orientation,
72-
check_timestamps_without_nans,
7383
check_timestamps_match_first_dimension,
74-
check_timestamp_of_the_first_sample_is_not_negative,
75-
check_rate_is_not_zero,
76-
)
77-
from ._icephys import (
78-
check_intracellular_electrode_cell_id_exists,
79-
)
80-
from ._behavior import (
81-
check_compass_direction_unit,
82-
check_spatial_series_radians_magnitude,
83-
check_spatial_series_dims,
84-
check_spatial_series_degrees_magnitude,
84+
check_timestamps_without_nans,
8585
)
8686

8787
__all__ = [

0 commit comments

Comments
 (0)