Skip to content

Commit

Permalink
Modernise these type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJCLaw committed Jan 8, 2024
1 parent 93a77f9 commit cc3a5fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/devdata/extras.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

import json
import textwrap
from pathlib import Path
from typing import Any, Callable, Dict, Set, Tuple
from typing import Any, Callable

from django.db import connections

Expand All @@ -14,7 +16,7 @@ class ExtraImport:
"""

name: str
depends_on = () # type: Tuple[str, ...]
depends_on: tuple[str, ...] = ()

def __init__(self) -> None:
pass
Expand All @@ -29,7 +31,7 @@ class ExtraExport:
Base extra defining how to get data out of an existing database.
"""

seen_names = set() # type: Set[str]
seen_names: set[str] = set()

def __init__(self, *args: Any, name: str, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -160,7 +162,7 @@ def import_data(self, django_dbname: str, src: Path) -> None:
with self.data_file(src).open() as f:
sequences = json.load(f)

def check_simple_value(mapping: Dict[str, str], *, key: str) -> str:
def check_simple_value(mapping: dict[str, str], *, key: str) -> str:
value = mapping[key]
if not value.replace("_", "").isalnum():
raise ValueError(f"{key} is not alphanumeric")
Expand Down
6 changes: 3 additions & 3 deletions src/devdata/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections.abc import Collection, Iterable
from pathlib import Path
from typing import Any, Callable, Set, Tuple, TypeVar
from typing import Any, Callable, TypeVar

from django.core import serializers
from django.core.serializers.base import DeserializedObject
Expand All @@ -27,7 +27,7 @@ class Strategy:
"""

name: str
depends_on = () # type: Tuple[str, ...]
depends_on: tuple[str, ...] = ()

def __init__(self) -> None:
pass
Expand All @@ -48,7 +48,7 @@ class Exportable:
database.
"""

seen_names = set() # type: Set[Tuple[str, str]]
seen_names: set[tuple[str, str]] = set()

def __init__(self, *args: Any, name: str, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
Expand Down

0 comments on commit cc3a5fb

Please sign in to comment.