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

clean up imports a bit #498

Merged
merged 4 commits into from
Sep 1, 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
4 changes: 1 addition & 3 deletions src/nwbinspector/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import jsonschema
import yaml

from nwbinspector.utils._utils import (
PathType,
)
from nwbinspector.utils import PathType

from . import available_checks
from ._registration import Importance
Expand Down
6 changes: 4 additions & 2 deletions src/nwbinspector/_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ def __init__(
self.message_counter = 0
self.formatted_messages = []

def _count_messages_by_importance(self, messages: List[InspectorMessage]) -> Dict[str, int]:
@staticmethod
def _count_messages_by_importance(messages: List[InspectorMessage]) -> Dict[str, int]:
message_count_by_importance = {importance_level.name: 0 for importance_level in Importance}
for message in messages:
message_count_by_importance[message.importance.name] += 1
for key in [keys for keys, count in message_count_by_importance.items() if count == 0]:
message_count_by_importance.pop(key)
return message_count_by_importance

def _get_name(self, obj) -> str:
@staticmethod
def _get_name(obj) -> str:
if isinstance(obj, Enum):
return obj.name
if isinstance(obj, str):
Expand Down
8 changes: 4 additions & 4 deletions src/nwbinspector/_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections import defaultdict
from concurrent.futures import ProcessPoolExecutor, as_completed
from pathlib import Path
from typing import Iterable, List, Optional, Union
from typing import Iterable, List, Optional, Type, Union
from warnings import filterwarnings, warn

import pynwb
Expand Down Expand Up @@ -37,7 +37,7 @@ def inspect_all(
n_jobs: int = 1,
skip_validate: bool = False,
progress_bar: bool = True,
progress_bar_class: tqdm = tqdm,
progress_bar_class: Type[tqdm] = tqdm,
progress_bar_options: Optional[dict] = None,
stream: bool = False,
version_id: Optional[str] = None,
Expand Down Expand Up @@ -421,7 +421,7 @@ def inspect_nwbfile_object(
def run_checks(
nwbfile: pynwb.NWBFile,
checks: list,
progress_bar_class: Optional[tqdm] = None,
progress_bar_class: Optional[Type[tqdm]] = None,
progress_bar_options: Optional[dict] = None,
) -> Iterable[InspectorMessage]:
"""
Expand All @@ -435,7 +435,7 @@ def run_checks(
The list of check functions that will be run on the in-memory pynwb.NWBFile object.
progress_bar_class : type of tqdm.tqdm, optional
The specific child class of tqdm.tqdm to use to make progress bars.
Defaults to not displaying progress per set of checks over an invidiual file.
Defaults to not displaying progress per set of checks over an individual file.
progress_bar_options : dict, optional
Dictionary of keyword arguments to pass directly to the `progress_bar_class`.

Expand Down
3 changes: 2 additions & 1 deletion tests/streaming_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def setUpClass(cls):
def tearDownClass(cls):
rmtree(cls.tempdir)

def assertFileExists(self, path: FilePathType):
@staticmethod
def assertFileExists(path: FilePathType):
path = Path(path)
assert path.exists()

Expand Down
3 changes: 2 additions & 1 deletion tests/test_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def add_simple_table(nwbfile: NWBFile):
class TestInspector(TestCase):
"""A common helper class for testing the NWBInspector."""

def assertFileExists(self, path: FilePathType):
@staticmethod
def assertFileExists(path: FilePathType):
path = Path(path)
assert path.exists()

Expand Down
3 changes: 1 addition & 2 deletions tests/unit_tests/test_nwb_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from pynwb import NWBContainer, NWBFile
from pynwb.image import ImageSeries

from nwbinspector import Importance, InspectorMessage
from nwbinspector._registration import Severity
from nwbinspector import Importance, InspectorMessage, Severity
from nwbinspector.checks import (
check_empty_string_for_optional_attribute,
check_large_dataset_compression,
Expand Down
Loading