-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate accessing Exchange classes directly from nbgrader.exchange
- Loading branch information
Showing
1 changed file
with
23 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
] |