Skip to content

Commit

Permalink
Avoid ParseError deprecation warning when not imported (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Sep 30, 2021
1 parent d39905b commit 7ab1636
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions openff/toolkit/typing/engines/smirnoff/forcefield.py
Expand Up @@ -23,7 +23,6 @@
"SMIRNOFFVersionError",
"SMIRNOFFAromaticityError",
"SMIRNOFFParseError",
"ParseError",
"PartialChargeVirtualSitesError",
"ForceField",
]
Expand All @@ -32,6 +31,7 @@
import logging
import os
import pathlib
import warnings
from collections import OrderedDict
from typing import List

Expand All @@ -49,7 +49,6 @@
from openff.toolkit.typing.engines.smirnoff.plugins import load_handler_plugins
from openff.toolkit.utils.exceptions import (
ParameterHandlerRegistrationError,
ParseError,
PartialChargeVirtualSitesError,
SMIRNOFFAromaticityError,
SMIRNOFFParseError,
Expand All @@ -64,6 +63,23 @@
requires_package,
)

deprecated_names = ["ParseError"]


def __getattr__(name):
if name in deprecated_names:
warnings.filterwarnings("default", category=DeprecationWarning)
warning_msg = f"{name} is DEPRECATED and will be removed in a future release of the OpenFF Toolkit."
warnings.warn(warning_msg, DeprecationWarning)

if name == "ParseError":
from openff.toolkit.utils.exceptions import _DeprecatedParseError

return _DeprecatedParseError

raise AttributeError(f"module {__name__} has no attribute {name}")


# =============================================================================================
# CONFIGURE LOGGER
# =============================================================================================
Expand Down

0 comments on commit 7ab1636

Please sign in to comment.