From: Jacob Lifshay Date: Fri, 26 Nov 2021 17:46:09 +0000 (-0800) Subject: add cached_property fallback for python < 3.8 compatability X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=52aeb922123a20f0298525a54701a0bf241e55c5;p=utils.git add cached_property fallback for python < 3.8 compatability --- diff --git a/setup.py b/setup.py index 72ed1ac..6b1f25a 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ from setuptools import setup, find_packages install_requires = [ "python-bugzilla", "toml", + "cached-property", ] setup( diff --git a/src/budget_sync/budget_graph.py b/src/budget_sync/budget_graph.py index 2bfa27d..483f36e 100644 --- a/src/budget_sync/budget_graph.py +++ b/src/budget_sync/budget_graph.py @@ -4,12 +4,16 @@ from typing import Callable, Set, Dict, Iterable, Optional, List, Tuple, Union, from budget_sync.util import BugStatus, PrettyPrinter from budget_sync.money import Money from budget_sync.config import Config, Person, Milestone -from functools import cached_property import toml import sys import enum from collections import deque from datetime import date, time, datetime +try: + from functools import cached_property +except ImportError: + # compatability with python < 3.8 + from cached_property import cached_property class BudgetGraphBaseError(Exception): diff --git a/src/budget_sync/config.py b/src/budget_sync/config.py index af7db98..5c9973d 100644 --- a/src/budget_sync/config.py +++ b/src/budget_sync/config.py @@ -3,7 +3,11 @@ from budget_sync.util import PrettyPrinter import toml import sys from typing import Mapping, Set, Dict, Any, Optional -from functools import cached_property +try: + from functools import cached_property +except ImportError: + # compatability with python < 3.8 + from cached_property import cached_property class ConfigParseError(Exception): diff --git a/src/budget_sync/test/mock_path.py b/src/budget_sync/test/mock_path.py index 33a7131..3fbe7cc 100644 --- a/src/budget_sync/test/mock_path.py +++ b/src/budget_sync/test/mock_path.py @@ -4,7 +4,11 @@ from os import PathLike from posixpath import normpath from enum import Enum import errno -from functools import cached_property +try: + from functools import cached_property +except ImportError: + # compatability with python < 3.8 + from cached_property import cached_property class MockDir(Enum):