Skip to content

Commit

Permalink
fix for 3.9?
Browse files Browse the repository at this point in the history
  • Loading branch information
pipliggins committed Nov 28, 2024
1 parent 4956466 commit 1badc8f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/adtl/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datetime import datetime
from functools import lru_cache
from pathlib import Path
from typing import Any, Callable, Iterable, Literal
from typing import Any, Callable, Iterable, Literal, Union

import fastjsonschema
import pint
Expand All @@ -29,8 +29,8 @@
DEFAULT_DATE_FORMAT = "%Y-%m-%d"

StrDict = dict[str, Any]
Rule = str | StrDict
Context = dict[str, bool | int | str | list[str]] | None
Rule = Union[str, StrDict]
Context = Union[dict[str, Union[bool, int, str, list[str]]], None]


def get_value(row: StrDict, rule: Rule, ctx: Context = None) -> Any:
Expand Down Expand Up @@ -341,7 +341,7 @@ def flatten(xs):
yield x


def expand_refs(spec_fragment: StrDict, defs: StrDict) -> StrDict | list[StrDict]:
def expand_refs(spec_fragment: StrDict, defs: StrDict) -> Union[StrDict, list[StrDict]]:
"Expand all references (ref) with definitions (defs)"

if spec_fragment == {}:
Expand All @@ -364,7 +364,7 @@ def expand_for(spec: list[StrDict]) -> list[StrDict]:
out = []

def replace_val(
item: str | float | dict[str, Any], replace: dict[str, Any]
item: Union[str, float, dict[str, Any]], replace: dict[str, Any]
) -> dict[str, Any]:
block = {}
if isinstance(item, str):
Expand Down Expand Up @@ -521,7 +521,7 @@ class Parser:

def __init__(
self,
spec: str | Path | StrDict,
spec: Union[str, Path, StrDict],
include_defs: list[str] = [],
quiet: bool = False,
):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import collections
import contextlib
import io
Expand Down
2 changes: 2 additions & 0 deletions tests/test_python_interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from pathlib import Path

import adtl
Expand Down
2 changes: 2 additions & 0 deletions tests/test_transformations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import datetime

import pytest
Expand Down

0 comments on commit 1badc8f

Please sign in to comment.