Skip to content

Commit

Permalink
Rename modaction.py to mod_action.py (#1166)
Browse files Browse the repository at this point in the history
Rename modaction.py to mod_action.py
  • Loading branch information
PythonCoderAS authored and bboe committed Dec 25, 2019
1 parent ffefec2 commit abceb30
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------
Expand Down
2 changes: 1 addition & 1 deletion praw/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions praw/models/mod_action.py
Original file line number Diff line number Diff line change
@@ -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
25 changes: 13 additions & 12 deletions praw/models/modaction.py
Original file line number Diff line number Diff line change
@@ -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,
)
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_deprecations.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit abceb30

Please sign in to comment.