diff --git a/CHANGES.rst b/CHANGES.rst index e8af02de8..caf214d54 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -33,6 +33,8 @@ Unreleased * :meth:`.moderator_subreddits` as :meth:`.Redditor.moderated` provides more functionality. +* The file for ModActions (praw/models/modaction.py) has been moved to + praw/models/mod_action.py and the previous has been Deprecated. 6.4.0 (2019/09/21) ------------------ diff --git a/praw/models/__init__.py b/praw/models/__init__.py index 1d80dc29c..0f585fbf0 100644 --- a/praw/models/__init__.py +++ b/praw/models/__init__.py @@ -8,7 +8,7 @@ from .listing.domain import DomainListing from .listing.generator import ListingGenerator from .listing.listing import Listing -from .modaction import ModAction +from .mod_action import ModAction from .preferences import Preferences from .reddit.collections import Collection from .reddit.comment import Comment diff --git a/praw/models/mod_action.py b/praw/models/mod_action.py new file mode 100644 index 000000000..3db84c6be --- /dev/null +++ b/praw/models/mod_action.py @@ -0,0 +1,16 @@ +"""Provide the ModAction class.""" + +from .base import PRAWBase + + +class ModAction(PRAWBase): + """Represent a moderator action.""" + + @property + def mod(self): + """Return the Redditor who the action was issued by.""" + return self._reddit.redditor(self._mod) # pylint: disable=no-member + + @mod.setter + def mod(self, value): + self._mod = value # pylint: disable=attribute-defined-outside-init diff --git a/praw/models/modaction.py b/praw/models/modaction.py index 3db84c6be..ddb2eda9a 100644 --- a/praw/models/modaction.py +++ b/praw/models/modaction.py @@ -1,16 +1,17 @@ -"""Provide the ModAction class.""" +"""A placeholder for the old modaction.py file. -from .base import PRAWBase +The new file can be found at praw/models/mod_action.py. +Do not import this module, as it is deprecated. +""" -class ModAction(PRAWBase): - """Represent a moderator action.""" +import warnings +from .mod_action import * # noqa - @property - def mod(self): - """Return the Redditor who the action was issued by.""" - return self._reddit.redditor(self._mod) # pylint: disable=no-member - - @mod.setter - def mod(self, value): - self._mod = value # pylint: disable=attribute-defined-outside-init +warnings.warn( + "The name modaction has been deprecated. " + "Please import modaction as mod_action. " + "This feature will be removed on the next major version release.", + DeprecationWarning, + stacklevel=2, +) diff --git a/tests/conftest.py b/tests/conftest.py index d00f6f370..ec1f74dc6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,6 +11,7 @@ import pytest from betamax_serializers import pretty_json + # pylint: disable=import-error,no-name-in-module if sys.version_info.major == 2: from urllib import quote_plus # NOQA diff --git a/tests/unit/test_deprecations.py b/tests/unit/test_deprecations.py new file mode 100644 index 000000000..a1a453cf7 --- /dev/null +++ b/tests/unit/test_deprecations.py @@ -0,0 +1,13 @@ +"""This file should be updated as files/classes/functions are deprecated.""" + +import pytest +from . import UnitTest +import warnings + + +class TestDeprecation(UnitTest): + def test_deprecation_modaction(self): + warnings.filterwarnings("error", category=DeprecationWarning) + with pytest.raises(DeprecationWarning): + import praw.models.modaction # noqa + warnings.filterwarnings("default", category=DeprecationWarning)