Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions news/dep-warning1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Add deprecation warning for ``diffpy.Structure`` import.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
26 changes: 25 additions & 1 deletion src/diffpy/structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
* SymmetryError
"""

# Interface definitions ------------------------------------------------------

import sys

import diffpy.structure as _structure
from diffpy.structure.atom import Atom
from diffpy.structure.lattice import Lattice
from diffpy.structure.parsers import getParser
Expand All @@ -45,6 +47,28 @@
# package version
from diffpy.structure.version import __version__

# Deprecations -------------------------------------------------------


# @deprecated
# custom deprecator for diffpy.Structure module
class DeprecatedStructureModule:
"""Proxy for backward compatibility of diffpy.Structure."""

def __getattr__(self, name):
import warnings

warnings.warn(
"Module 'diffpy.Structure' is deprecated and will be removed in version 4.0. "
"Use 'diffpy.structure' instead.",
DeprecationWarning,
stacklevel=2,
)
return getattr(_structure, name)


sys.modules["diffpy.Structure"] = DeprecatedStructureModule()

# top level routines


Expand Down
Loading