Skip to content

Commit

Permalink
TypedDict from typing_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat committed Jan 25, 2025
1 parent 209aaed commit 24a1a52
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
10 changes: 7 additions & 3 deletions mio/models/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
from abc import abstractmethod
from datetime import datetime
from graphlib import TopologicalSorter
from typing import Any, ClassVar, Generic, Optional, TypedDict, TypeVar, Union, Unpack, final
from typing import Any, ClassVar, Generic, Optional, TypeVar, Union, Unpack, final

from pydantic import Field, field_validator, model_validator

from mio.exceptions import ConfigurationMismatchError
from mio.models.models import MiniscopeConfig, PipelineModel

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
from typing_extensions import Self, TypedDict
elif sys.version_info < (3, 12):
from typing import Self

from typing_extensions import TypedDict
else:
from typing import Self, TypedDict

T = TypeVar("T")
"""
Input Type typevar
Expand Down
8 changes: 7 additions & 1 deletion mio/sinks/return_.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
Special Return sink that pipeline runners use to return values from :meth:`.PipelineRunner.process`
"""

from typing import Any, Optional, TypedDict
import sys
from typing import Any, Optional

from mio.models.pipeline import Sink, T

if sys.version_info < (3, 12):
from typing_extensions import TypedDict
else:
from typing import TypedDict


class ReturnConfig(TypedDict):
"""
Expand Down
9 changes: 7 additions & 2 deletions mio/sources/file.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
File-based data sources
"""

import sys
from pathlib import Path
from typing import BinaryIO, ClassVar, Optional, TypedDict
from typing import BinaryIO, ClassVar, Optional

import numpy as np
from pydantic import Field
Expand All @@ -12,6 +12,11 @@
from mio.models.pipeline import Source
from mio.models.sdcard import SDBufferHeader, SDConfig, SDLayout

if sys.version_info < (3, 12):
from typing_extensions import TypedDict
else:
from typing import TypedDict


class FileSource(Source):
"""
Expand Down
9 changes: 7 additions & 2 deletions mio/transforms/frame.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
"""
Nodes that receive and emit frames
"""

from typing import Optional, TypedDict
import sys
from typing import Optional

import numpy as np

from mio.models.buffer import BufferHeader
from mio.models.data import Frame
from mio.models.pipeline import Transform

if sys.version_info < (3, 12):
from typing_extensions import TypedDict
else:
from typing import TypedDict


class MergeBuffersConfig(TypedDict):
"""Configuration for :class:`.MergeBuffers`"""
Expand Down

0 comments on commit 24a1a52

Please sign in to comment.