From 3e1ae44eb9f0c2bd7d63d8a304e911066378218b Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 20 Nov 2019 20:13:28 -0800 Subject: [PATCH] REF: make Fixed.version a property --- pandas/io/pytables.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 7c447cbf78677..f060831a1a036 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -9,7 +9,7 @@ import os import re import time -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, Union +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union import warnings import numpy as np @@ -2560,21 +2560,22 @@ def __init__(self, parent, group, encoding=None, errors="strict", **kwargs): self.group = group self.encoding = _ensure_encoding(encoding) self.errors = errors - self.set_version() @property def is_old_version(self) -> bool: return self.version[0] <= 0 and self.version[1] <= 10 and self.version[2] < 1 - def set_version(self): + @property + def version(self) -> Tuple[int, int, int]: """ compute and set our version """ version = _ensure_decoded(getattr(self.group._v_attrs, "pandas_version", None)) try: - self.version = tuple(int(x) for x in version.split(".")) - if len(self.version) == 2: - self.version = self.version + (0,) + version = tuple(int(x) for x in version.split(".")) + if len(version) == 2: + version = version + (0,) except AttributeError: - self.version = (0, 0, 0) + version = (0, 0, 0) + return version @property def pandas_type(self): @@ -2600,7 +2601,6 @@ def set_object_info(self): """ set my pandas type & version """ self.attrs.pandas_type = str(self.pandas_kind) self.attrs.pandas_version = str(_version) - self.set_version() def copy(self): new_self = copy.copy(self)