Skip to content

Commit

Permalink
Put try/except for cached_property backport in _compat
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Dec 2, 2020
1 parent 81505c6 commit d7d227b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
13 changes: 8 additions & 5 deletions satpy/_compat.py
Expand Up @@ -17,9 +17,12 @@
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""Backports and compatibility fixes for satpy."""

from functools import lru_cache
try:
from functools import cached_property
except ImportError:
# for python < 3.8
from functools import lru_cache


def cached_property(func):
"""Port back functools.cached_property."""
return property(lru_cache(maxsize=None)(func))
def cached_property(func):
"""Port back functools.cached_property."""
return property(lru_cache(maxsize=None)(func))
7 changes: 1 addition & 6 deletions satpy/readers/abi_base.py
Expand Up @@ -26,15 +26,10 @@
from pyresample import geometry

from satpy import CHUNK_SIZE
from satpy._compat import cached_property
from satpy.readers import open_file_or_filename
from satpy.readers.file_handlers import BaseFileHandler

try:
from functools import cached_property
except ImportError:
# for python < 3.8
from satpy._compat import cached_property

logger = logging.getLogger(__name__)

PLATFORM_NAMES = {
Expand Down
6 changes: 1 addition & 5 deletions satpy/readers/olci_nc.py
Expand Up @@ -52,11 +52,7 @@
from satpy.readers.file_handlers import BaseFileHandler
from satpy.utils import angle2xyz, xyz2angle

try:
from functools import cached_property
except ImportError:
# for python < 3.8
from satpy._compat import cached_property
from satpy._compat import cached_property

logger = logging.getLogger(__name__)

Expand Down

0 comments on commit d7d227b

Please sign in to comment.