Skip to content

Commit

Permalink
Deprecate accessing Exchange classes directly from nbgrader.exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
shreve committed Jan 3, 2024
1 parent d98324c commit 4c51c81
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions nbgrader/exchange/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
from nbgrader.exchange.abc import (Exchange, ExchangeError, ExchangeCollect, ExchangeFetch, ExchangeFetchAssignment,
ExchangeFetchFeedback, ExchangeList, ExchangeReleaseAssignment, ExchangeRelease,
ExchangeReleaseFeedback, ExchangeSubmit, ExchangeReleaseFeedback)
from nbgrader.exchange import default
import warnings
from nbgrader.exchange.abc import ExchangeError
from nbgrader.exchange import abc, default
from .exchange_factory import ExchangeFactory

def __getattr__(name):
if name in abc.__all__:
warnings.warn(
f"Importing {name} from nbgrader.exchange is deprecated."
" Import from nbgrader.exchange.abc or the specific "
" exchange implementation instead.".format(name),
DeprecationWarning,
stacklevel=2
)

if hasattr(abc, name):
return getattr(abc, name)
elif hasattr(default, name):
return getattr(default, name)

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

__all__ = [
"Exchange",
"ExchangeError",
"ExchangeCollect",
"ExchangeFetch",
"ExchangeFetchAssignment",
"ExchangeFetchFeedback",
"ExchangeList",
"ExchangeRelease",
"ExchangeReleaseAssignment",
"ExchangeReleaseFeedback",
"ExchangeSubmit",
"abc",
"default",
"ExchangeFactory",
"default"
"ExchangeError",
]

0 comments on commit 4c51c81

Please sign in to comment.