Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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>
25 changes: 24 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,27 @@
# 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. Use 'diffpy.structure' instead.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is deprecated and will be removed in version 3.8. Use 'diffpy.structure' instead

DeprecationWarning,
stacklevel=2,
)
return getattr(_structure, name)


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

# top level routines


Expand Down
Loading