From: Scott Gasch Date: Fri, 9 Jun 2023 02:49:46 +0000 (-0700) Subject: Merge simple and typing. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=cb8139c69b673cce0b1332e75bcb1bb9c999d2ee;p=pyutils.git Merge simple and typing. --- diff --git a/src/pyutils/collectionz/interval_tree.py b/src/pyutils/collectionz/interval_tree.py index 9542e21..7cd40cf 100644 --- a/src/pyutils/collectionz/interval_tree.py +++ b/src/pyutils/collectionz/interval_tree.py @@ -14,7 +14,7 @@ from typing import Any, Generator, Optional from overrides import overrides from pyutils.collectionz import bst -from pyutils.typez.simple import Numeric +from pyutils.typez.typing import Numeric @total_ordering diff --git a/src/pyutils/graph.py b/src/pyutils/graph.py index faa0ec3..376a364 100644 --- a/src/pyutils/graph.py +++ b/src/pyutils/graph.py @@ -10,7 +10,7 @@ import math from typing import Dict, Generator, List, Optional, Set, Tuple from pyutils import list_utils -from pyutils.typez.simple import Numeric +from pyutils.typez.typing import Numeric class Graph(object): diff --git a/src/pyutils/math_utils.py b/src/pyutils/math_utils.py index 4ceee8c..8ec47d2 100644 --- a/src/pyutils/math_utils.py +++ b/src/pyutils/math_utils.py @@ -11,7 +11,7 @@ from heapq import heappop, heappush from typing import Dict, List, Optional, Tuple from pyutils import dict_utils -from pyutils.typez.simple import Numeric +from pyutils.typez.typing import Numeric class NumericPopulation(object): @@ -124,7 +124,7 @@ class NumericPopulation(object): count[-n] += 1 for n in self.highers: count[n] += 1 - return dict_utils.item_with_max_value(count) + return dict_utils.item_with_max_value(count) # type: ignore def get_stdev(self) -> float: """ diff --git a/src/pyutils/typez/simple.py b/src/pyutils/typez/simple.py deleted file mode 100644 index 4165fc5..0000000 --- a/src/pyutils/typez/simple.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -# © Copyright 2021-2023, Scott Gasch - -"""Simple type helpers.""" - -from typing import Union - -Numeric = Union[int, float] diff --git a/src/pyutils/typez/typing.py b/src/pyutils/typez/typing.py index bed5e7f..cd0f0a5 100644 --- a/src/pyutils/typez/typing.py +++ b/src/pyutils/typez/typing.py @@ -5,7 +5,9 @@ """My type hints.""" from abc import abstractmethod -from typing import Any, Protocol +from typing import Any, Protocol, Union + +Numeric = Union[int, float] class Comparable(Protocol):