Skip to content

Commit

Permalink
refactor: import cached-property from functools when the python versi…
Browse files Browse the repository at this point in the history
…on is newer than 3.8
  • Loading branch information
e3243eric committed Sep 28, 2022
1 parent f307dfb commit fedde16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions eth_utils/logging.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import contextlib
import logging
import sys
from typing import Any, Dict, Iterator, Tuple, Type, TypeVar, cast

from cached_property import cached_property

from .toolz import assoc

if sys.version_info < (3, 8):
from cached_property import cached_property
else:
from functools import cached_property

DEBUG2_LEVEL_NUM = 8

TLogger = TypeVar("TLogger", bound=logging.Logger)
Expand All @@ -16,7 +20,7 @@ class ExtendedDebugLogger(logging.Logger):
Logging class that can be used for lower level debug logging.
"""

@cached_property # type: ignore
@cached_property # typing: ignore
def show_debug2(self) -> bool:
return self.isEnabledFor(DEBUG2_LEVEL_NUM)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
url="https://github.com/ethereum/eth-utils",
include_package_data=True,
install_requires=[
"cached-property>=1.5.2,<2",
"cached-property>=1.5.2,<2;python_version<'3.8'",
"eth-hash>=0.3.1,<0.6.0",
"eth-typing>=3.0.0,<4.0.0",
"toolz>0.8.2,<1;implementation_name=='pypy'",
Expand Down

0 comments on commit fedde16

Please sign in to comment.