Skip to content

Commit

Permalink
Replace attrdict to addict for python 3.10 compatibility (#108)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
GyeonghunKim authored May 25, 2022
1 parent 3446d23 commit 523af53
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
8 changes: 1 addition & 7 deletions pyEPR/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions pyEPR/toolbox/pythonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
attrdict>=1.8.0
addict
numpy>=1.15.0
pandas>=1.0.1
matplotlib>=3.1.0
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down

0 comments on commit 523af53

Please sign in to comment.