Skip to content

Commit

Permalink
Modernize type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Nov 8, 2023
1 parent a72ebe9 commit df34c80
Show file tree
Hide file tree
Showing 38 changed files with 462 additions and 495 deletions.
6 changes: 2 additions & 4 deletions dandi/cli/cmd_move.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from typing import Optional

import click

from .base import devel_debug_option, instance_option, map_to_click_exceptions
Expand Down Expand Up @@ -47,10 +45,10 @@
@map_to_click_exceptions
def move(
paths: tuple[str],
dandiset: Optional[str],
dandiset: str | None,
dry_run: bool,
existing: str,
jobs: Optional[int],
jobs: int | None,
regex: bool,
work_on: str,
dandi_instance: str,
Expand Down
16 changes: 8 additions & 8 deletions dandi/cli/cmd_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import os
import re
from typing import List, Optional, cast
from typing import cast
import warnings

import click
Expand Down Expand Up @@ -90,10 +90,10 @@ def validate_bids(
@map_to_click_exceptions
def validate(
paths: tuple[str, ...],
ignore: Optional[str],
ignore: str | None,
grouping: str,
min_severity: str,
schema: Optional[str] = None,
schema: str | None = None,
devel_debug: bool = False,
allow_any_path: bool = False,
) -> None:
Expand Down Expand Up @@ -139,7 +139,7 @@ def validate(
def _process_issues(
validator_result: Iterable[ValidationResult],
grouping: str,
ignore: Optional[str] = None,
ignore: str | None = None,
) -> None:
issues = [i for i in validator_result if i.severity is not None]
if ignore is not None:
Expand All @@ -149,7 +149,7 @@ def _process_issues(
display_errors(
purviews,
[i.id for i in issues],
cast(List[Severity], [i.severity for i in issues]),
cast("list[Severity]", [i.severity for i in issues]),
[i.message for i in issues],
)
elif grouping == "path":
Expand All @@ -161,7 +161,7 @@ def _process_issues(
display_errors(
[purview],
[i.id for i in applies_to],
cast(List[Severity], [i.severity for i in applies_to]),
cast("list[Severity]", [i.severity for i in applies_to]),
[i.message for i in applies_to],
)
else:
Expand All @@ -185,10 +185,10 @@ def _get_severity_color(severities: list[Severity]) -> str:


def display_errors(
purviews: list[Optional[str]],
purviews: list[str | None],
errors: list[str],
severities: list[Severity],
messages: list[Optional[str]],
messages: list[str | None],
) -> None:
"""
Unified error display for validation CLI, which auto-resolves grouping
Expand Down
4 changes: 2 additions & 2 deletions dandi/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from __future__ import annotations

from _pytest.config import Config
from _pytest.config.argparsing import Parser
Expand All @@ -16,7 +16,7 @@ def pytest_addoption(parser: Parser) -> None:
)


def pytest_collection_modifyitems(items: List[Item], config: Config) -> None:
def pytest_collection_modifyitems(items: list[Item], config: Config) -> None:
# Based on <https://pythontesting.net/framework/pytest/pytest-run-tests
# -using-particular-fixture/>
if config.getoption("--dandi-api"):
Expand Down
3 changes: 1 addition & 2 deletions dandi/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from dataclasses import dataclass
from enum import Enum
import os
from typing import Optional

#: A list of metadata fields which dandi extracts from .nwb files.
#: Additional fields (such as ``number_of_*``) might be added by
Expand Down Expand Up @@ -99,7 +98,7 @@ class EmbargoStatus(Enum):
@dataclass(frozen=True)
class DandiInstance:
name: str
gui: Optional[str]
gui: str | None
api: str

@property
Expand Down
Loading

0 comments on commit df34c80

Please sign in to comment.