From 523af53c56df9805e2f573f9cce9cb45efb59c0f Mon Sep 17 00:00:00 2001 From: GyeonghunKim <34947229+GyeonghunKim@users.noreply.github.com> Date: Thu, 26 May 2022 01:16:22 +0900 Subject: [PATCH] Replace attrdict to addict for python 3.10 compatibility (#108) * Replace Attrdict to addict.Dict for python>=3.10 compatibility * Add one line for filtering addict.Dict from obj's attributes. * replace attrdict to addict * add python 3.10 to classifiers * Add python 3.9 in setup.py --- pyEPR/__init__.py | 8 +------- pyEPR/toolbox/pythonic.py | 8 +++++--- requirements.txt | 2 +- setup.py | 2 ++ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pyEPR/__init__.py b/pyEPR/__init__.py index 1c76675..f15ea58 100644 --- a/pyEPR/__init__.py +++ b/pyEPR/__init__.py @@ -74,13 +74,7 @@ import warnings from pathlib import Path -try: - from attrdict import AttrDict as Dict -except (ImportError, ModuleNotFoundError): - raise ImportError("""Please install python package `AttrDict`. - AttrDict is in PyPI, so it can be installed directly - (https://github.com/bcj/AttrDict) using: - $ pip install attrdict""") +from addict import Dict ############################################################################## # Python header diff --git a/pyEPR/toolbox/pythonic.py b/pyEPR/toolbox/pythonic.py index d0b015c..d3a37ae 100644 --- a/pyEPR/toolbox/pythonic.py +++ b/pyEPR/toolbox/pythonic.py @@ -14,7 +14,7 @@ # Constants from collections import OrderedDict from ..calcs.constants import Planck, elementary_charge, epsilon_0, pi, π, ħ, ϕ0, e_el - +from .. import Dict # ============================================================================== # Utility functions @@ -177,8 +177,10 @@ def get_instance_vars(obj, Forbidden=[]): for v in dir(obj): if not (v.startswith('__') or v.startswith('_')): if not callable(getattr(obj, v)): - if not (v in Forbidden): - VARS[v] = getattr(obj, v) + # Added for using addict.Dict which is not callable. + if not isinstance(getattr(obj, v), Dict): + if not (v in Forbidden): + VARS[v] = getattr(obj, v) return VARS diff --git a/requirements.txt b/requirements.txt index 701a392..bc257ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -attrdict>=1.8.0 +addict numpy>=1.15.0 pandas>=1.0.1 matplotlib>=3.1.0 diff --git a/setup.py b/setup.py index dd50639..f770369 100644 --- a/setup.py +++ b/setup.py @@ -51,6 +51,8 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Topic :: Scientific/Engineering", "Environment :: Console", "License :: OSI Approved :: Apache Software License" ],