Skip to content

Commit 730a91e

Browse files
authored
Merge pull request #149 from cadenmyers13/dep-warning1
deprecate: Add deprecation warning for `diffpy.Structure`
2 parents 2316eaa + 3c462a7 commit 730a91e

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

news/dep-warning1.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Add deprecation warning for ``diffpy.Structure`` import.
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

src/diffpy/structure/__init__.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
* SymmetryError
3434
"""
3535

36-
# Interface definitions ------------------------------------------------------
3736

37+
import sys
38+
39+
import diffpy.structure as _structure
3840
from diffpy.structure.atom import Atom
3941
from diffpy.structure.lattice import Lattice
4042
from diffpy.structure.parsers import getParser
@@ -45,6 +47,28 @@
4547
# package version
4648
from diffpy.structure.version import __version__
4749

50+
# Deprecations -------------------------------------------------------
51+
52+
53+
# @deprecated
54+
# custom deprecator for diffpy.Structure module
55+
class DeprecatedStructureModule:
56+
"""Proxy for backward compatibility of diffpy.Structure."""
57+
58+
def __getattr__(self, name):
59+
import warnings
60+
61+
warnings.warn(
62+
"Module 'diffpy.Structure' is deprecated and will be removed in version 4.0. "
63+
"Use 'diffpy.structure' instead.",
64+
DeprecationWarning,
65+
stacklevel=2,
66+
)
67+
return getattr(_structure, name)
68+
69+
70+
sys.modules["diffpy.Structure"] = DeprecatedStructureModule()
71+
4872
# top level routines
4973

5074

0 commit comments

Comments
 (0)