Skip to content

Commit

Permalink
Merge pull request #214 from praw-dev/standardize_quotes
Browse files Browse the repository at this point in the history
Standardize quotes in error messages and stdout messages
  • Loading branch information
LilSpazJoekp committed Nov 28, 2022
2 parents 460ab97 + e6b7455 commit 3bb04b0
Show file tree
Hide file tree
Showing 42 changed files with 124 additions and 124 deletions.
2 changes: 1 addition & 1 deletion asyncpraw/config.py
@@ -1,4 +1,4 @@
"""Provides the code to load Async PRAW's configuration file `praw.ini`."""
"""Provides the code to load Async PRAW's configuration file ``praw.ini``."""
import configparser
import os
import sys
Expand Down
12 changes: 6 additions & 6 deletions asyncpraw/exceptions.py
Expand Up @@ -143,7 +143,7 @@ def field(self) -> str:

def _get_old_attr(self, attrname):
warn(
f"Accessing attribute ``{attrname}`` through APIException is deprecated."
f"Accessing attribute '{attrname}' through APIException is deprecated."
" This behavior will be removed in Async PRAW 8.0. Check out"
" https://praw.readthedocs.io/en/latest/package_info/praw7_migration.html"
" to learn how to migrate your code.",
Expand Down Expand Up @@ -188,7 +188,7 @@ def __init__(self):
"""Initialize a :class:`.DuplicateReplaceException` instance."""
super().__init__(
"A duplicate comment has been detected. Are you attempting to call"
" ``replace_more_comments`` more than once?"
" 'replace_more_comments' more than once?"
)


Expand All @@ -198,8 +198,8 @@ class InvalidFlairTemplateID(ClientException):
def __init__(self, template_id: str):
"""Initialize an :class:`.InvalidFlairTemplateID` instance."""
super().__init__(
f"The flair template ID ``{template_id}`` is invalid. If you are trying to"
" create a flair, please use the ``add`` method."
f"The flair template ID '{template_id}' is invalid. If you are trying to"
" create a flair, please use the 'add' method."
)


Expand Down Expand Up @@ -258,9 +258,9 @@ class WebSocketException(ClientException):

@property
def original_exception(self) -> Exception:
"""Access the original_exception attribute (now deprecated)."""
"""Access the ``original_exception`` attribute (now deprecated)."""
warn(
"Accessing the attribute original_exception is deprecated. Please rewrite"
"Accessing the attribute 'original_exception' is deprecated. Please rewrite"
" your code in such a way that this attribute does not need to be used. It"
" will be removed in Async PRAW 8.0.",
category=DeprecationWarning,
Expand Down
4 changes: 2 additions & 2 deletions asyncpraw/models/helpers.py
Expand Up @@ -127,7 +127,7 @@ async def create(
"""
if selftext and url:
raise TypeError("Exactly one of `selftext` or `url` must be provided.")
raise TypeError("Exactly one of 'selftext' or 'url' must be provided.")
if isinstance(subreddit, str):
subreddit = await self._reddit.subreddit(subreddit)

Expand Down Expand Up @@ -242,7 +242,7 @@ async def create(
:param resources: Markdown formatted information that is useful for the
:class:`.LiveThread`.
:returns: The new :class`.LiveThread` object.
:returns: The new :class:`.LiveThread` object.
"""
return await self._reddit.post(
Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/list/trophy.py
Expand Up @@ -5,7 +5,7 @@
class TrophyList(BaseList):
"""A list of :class:`.Trophy` objects. Works just like a regular list.
This class is solely used to parse responses from reddit, so end users should not
This class is solely used to parse responses from Reddit, so end users should not
use this class directly.
"""
Expand Down
6 changes: 4 additions & 2 deletions asyncpraw/models/listing/mixins/base.py
Expand Up @@ -20,8 +20,10 @@ def _validate_time_filter(time_filter):
"""
if time_filter not in BaseListingMixin.VALID_TIME_FILTERS:
valid_time_filters = ", ".join(BaseListingMixin.VALID_TIME_FILTERS)
raise ValueError(f"time_filter must be one of: {valid_time_filters}")
valid_time_filters = ", ".join(
map("{!r}".format, BaseListingMixin.VALID_TIME_FILTERS)
)
raise ValueError(f"'time_filter' must be one of: {valid_time_filters}")

def _prepare(self, *, arguments, sort):
"""Fix for :class:`.Redditor` methods that use a query param rather than subpath."""
Expand Down
24 changes: 12 additions & 12 deletions asyncpraw/models/mod_notes.py
Expand Up @@ -166,14 +166,14 @@ async def create(
redditor = getattr(self, "redditor", redditor) or thing.author
subreddit = getattr(self, "subreddit", subreddit) or thing.subreddit
redditor = self._ensure_attribute(
"Either the `redditor` or `thing` parameters must be provided or this"
" method must be called from a Redditor instance (e.g., `redditor.notes`).",
"Either the 'redditor' or 'thing' parameters must be provided or this"
" method must be called from a Redditor instance (e.g., 'redditor.notes').",
redditor=redditor,
)
subreddit = self._ensure_attribute(
"Either the `subreddit` or `thing` parameters must be provided or this"
"Either the 'subreddit' or 'thing' parameters must be provided or this"
" method must be called from a Subreddit instance (e.g.,"
" `subreddit.mod.notes`).",
" 'subreddit.mod.notes').",
subreddit=subreddit,
)
data = {
Expand Down Expand Up @@ -259,17 +259,17 @@ async def delete(
"""
redditor = self._ensure_attribute(
"Either the `redditor` parameter must be provided or this method must be called"
" from a Redditor instance (e.g., `redditor.notes`).",
"Either the 'redditor' parameter must be provided or this method must be"
" called from a Redditor instance (e.g., 'redditor.notes').",
redditor=redditor,
)
subreddit = self._ensure_attribute(
"Either the `subreddit` parameter must be provided or this method must be called"
" from a Subreddit instance (e.g., `subreddit.mod.notes`).",
"Either the 'subreddit' parameter must be provided or this method must be"
" called from a Subreddit instance (e.g., 'subreddit.mod.notes').",
subreddit=subreddit,
)
if not delete_all and note_id is None:
raise TypeError("Either `note_id` or `delete_all` must be provided.")
raise TypeError("Either 'note_id' or 'delete_all' must be provided.")
if delete_all:
async for note in self._notes(True, [redditor], [subreddit]):
await note.delete()
Expand Down Expand Up @@ -423,17 +423,17 @@ def __call__(
things = []
if not (pairs + redditors + subreddits + things):
raise TypeError(
"Either the `pairs`, `redditors`, `subreddits`, or `things` parameters"
"Either the 'pairs', 'redditors', 'subreddits', or 'things' parameters"
" must be provided."
)
if (
len(redditors) * len(subreddits) == 0
and len(redditors) + len(subreddits) > 0
):
raise TypeError(
"`redditors` must be non-empty if `subreddits` is not empty."
"'redditors' must be non-empty if 'subreddits' is not empty."
if len(subreddits) > 0
else "`subreddits` must be non-empty if `redditors` is not empty."
else "'subreddits' must be non-empty if 'redditors' is not empty."
)

merged_redditors = []
Expand Down
5 changes: 3 additions & 2 deletions asyncpraw/models/reddit/collections.py
Expand Up @@ -321,7 +321,8 @@ def __init__(
"""
if (_data, collection_id, permalink).count(None) != 2:
raise TypeError(
"Exactly one of _data, collection_id, or permalink must be provided."
"Exactly one of '_data', 'collection_id', or 'permalink' must be"
" provided."
)

if permalink:
Expand Down Expand Up @@ -594,7 +595,7 @@ async def __call__(
"""
if (collection_id is None) == (permalink is None):
raise TypeError(
"Exactly one of collection_id or permalink must be provided."
"Exactly one of 'collection_id' or 'permalink' must be provided."
)
collection = Collection(
self._reddit, collection_id=collection_id, permalink=permalink
Expand Down
4 changes: 2 additions & 2 deletions asyncpraw/models/reddit/comment.py
Expand Up @@ -161,7 +161,7 @@ def __init__(
):
"""Initialize a :class:`.Comment` instance."""
if (id, url, _data).count(None) != 2:
raise TypeError("Exactly one of `id`, `url`, or `_data` must be provided.")
raise TypeError("Exactly one of 'id', 'url', or '_data' must be provided.")
fetched = False
self._replies = []
self._submission = None
Expand Down Expand Up @@ -238,7 +238,7 @@ async def parent(
comment = await reddit.comment("cklhv0f", fetch=False)
parent = await comment.parent()
# `replies` is empty until the comment is refreshed
# 'replies' is empty until the comment is refreshed
print(parent.replies) # Output: []
await parent.refresh()
print(parent.replies) # Output is at least: [Comment(id="cklhv0f")]
Expand Down
5 changes: 3 additions & 2 deletions asyncpraw/models/reddit/draft.py
Expand Up @@ -94,7 +94,7 @@ def __init__(
):
"""Initialize a :class:`.Draft` instance."""
if (id, _data).count(None) != 1:
raise TypeError("Exactly one of `id` or `_data` must be provided.")
raise TypeError("Exactly one of 'id' or '_data' must be provided.")
fetched = False
if id:
self.id = id
Expand Down Expand Up @@ -288,7 +288,8 @@ async def submit(
submit_kwargs["draft_id"] = self.id
if not (self.subreddit or subreddit):
raise ValueError(
"`subreddit` must be set on the Draft or passed as a keyword argument."
"'subreddit' must be set on the Draft instance or passed as a keyword"
" argument."
)
for key, attribute in [
("flair_id", flair_id),
Expand Down
8 changes: 4 additions & 4 deletions asyncpraw/models/reddit/live.py
Expand Up @@ -416,7 +416,7 @@ def __init__(
"""
if (id, _data).count(None) != 1:
raise TypeError("Either `id` or `_data` must be provided.")
raise TypeError("Either 'id' or '_data' must be provided.")
if id:
self.id = id
super().__init__(reddit, _data=_data)
Expand Down Expand Up @@ -591,15 +591,15 @@ async def update(
thread = await reddit.live("xyu8kmjvfrww")
# update `title` and `nsfw`
# update 'title' and 'nsfw'
updated_thread = await thread.contrib.update(title=new_title, nsfw=True)
If Reddit introduces new settings, you must specify ``None`` for the setting you
want to maintain:
.. code-block:: python
# update `nsfw` and maintain new setting `foo`
# update 'nsfw' and maintain new setting 'foo'
await thread.contrib.update(nsfw=True, foo=None)
"""
Expand Down Expand Up @@ -764,7 +764,7 @@ def __init__(
self._thread = LiveThread(self._reddit, thread_id)
else:
raise TypeError(
"Either `thread_id` and `update_id`, or `_data` must be provided."
"Either 'thread_id' and 'update_id', or '_data' must be provided."
)

def __setattr__(self, attribute: str, value: Any):
Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/reddit/mixins/gildable.py
Expand Up @@ -110,7 +110,7 @@ async def award(
async def gild(self) -> dict:
"""Alias for :meth:`.award` to maintain backwards compatibility."""
warn(
"`.gild` has been renamed to `.award`.",
"'.gild' has been renamed to '.award'.",
category=DeprecationWarning,
stacklevel=2,
)
Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/reddit/modmail.py
Expand Up @@ -123,7 +123,7 @@ def __init__(
"""
if bool(id) == bool(_data):
raise TypeError("Either `id` or `_data` must be provided.")
raise TypeError("Either 'id' or '_data' must be provided.")

if id:
self.id = id
Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/reddit/redditor.py
Expand Up @@ -156,7 +156,7 @@ def __init__(
"""
if (name, fullname, _data).count(None) != 2:
raise TypeError(
"Exactly one of `name`, `fullname`, or `_data` must be provided."
"Exactly one of 'name', 'fullname', or '_data' must be provided."
)
if _data:
assert (
Expand Down
8 changes: 4 additions & 4 deletions asyncpraw/models/reddit/removal_reasons.py
Expand Up @@ -40,10 +40,10 @@ def _warn_reason_id(*, id_value: Optional[str], reason_id_value: Optional[str]):
"""
if reason_id_value is not None:
warn(
"Parameter ``reason_id`` is deprecated. Either use positional"
' arguments (reason_id="x" -> "x") or change the parameter '
'name to ``id`` (reason_id="x" -> id="x"). The parameter will'
" be removed in Async PRAW 8.",
"Parameter 'reason_id' is deprecated. Either use positional arguments"
' (e.g., reason_id="x" -> "x") or change the parameter name to \'id\''
' (e.g., reason_id="x" -> id="x"). This parameter will be removed in'
" Async PRAW 8.",
category=DeprecationWarning,
stacklevel=3,
)
Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/reddit/submission.py
Expand Up @@ -560,7 +560,7 @@ def __init__(
"""
if (id, url, _data).count(None) != 2:
raise TypeError("Exactly one of `id`, `url`, or `_data` must be provided.")
raise TypeError("Exactly one of 'id', 'url', or '_data' must be provided.")
self.comment_limit = 2048

# Specify the sort order for ``comments``
Expand Down
14 changes: 7 additions & 7 deletions asyncpraw/models/reddit/subreddit.py
Expand Up @@ -610,7 +610,7 @@ def __init__(
"""
if (display_name, _data).count(None) != 1:
raise TypeError("Either `display_name` or `_data` must be provided.")
raise TypeError("Either 'display_name' or '_data' must be provided.")
if display_name:
self.display_name = display_name
super().__init__(reddit, _data=_data)
Expand Down Expand Up @@ -658,7 +658,7 @@ def _parse_xml_response(self, response: ClientResponse):
async def _submit_media(
self, *, data: Dict[Any, Any], timeout: int, websocket_url: Optional[str] = None
):
"""Submit and return an `image`, `video`, or `videogif`.
"""Submit and return an ``image``, ``video``, or ``videogif``.
This is a helper method for submitting posts that are not link posts or self
posts.
Expand Down Expand Up @@ -1056,7 +1056,7 @@ async def submit(
"""
if (bool(selftext) or selftext == "") == bool(url):
raise TypeError("Either `selftext` or `url` must be provided.")
raise TypeError("Either 'selftext' or 'url' must be provided.")

data = {
"sr": str(self),
Expand Down Expand Up @@ -1920,8 +1920,8 @@ async def set(
"""
if css_class and flair_template_id is not None:
raise TypeError(
"Parameter `css_class` cannot be used in conjunction with"
" `flair_template_id`."
"Parameter 'css_class' cannot be used in conjunction with"
" 'flair_template_id'."
)
data = {"name": str(redditor), "text": text}
if flair_template_id is not None:
Expand Down Expand Up @@ -3753,7 +3753,7 @@ def conversations(
params = {}
if after:
warn(
"The `after` argument is deprecated and should be moved to the `params`"
"The 'after' argument is deprecated and should be moved to the 'params'"
" dictionary argument.",
category=DeprecationWarning,
stacklevel=3,
Expand Down Expand Up @@ -4239,7 +4239,7 @@ async def upload_banner_additional_image(
if align is not None:
if align not in {"left", "centered", "right"}:
raise ValueError(
"align argument must be either `left`, `centered`, or `right`"
"'align' argument must be either 'left', 'centered', or 'right'"
)
alignment["bannerPositionedImagePosition"] = align

Expand Down
8 changes: 4 additions & 4 deletions asyncpraw/models/reddit/user_subreddit.py
Expand Up @@ -92,8 +92,8 @@ def _dict_depreciated_wrapper(func):

def wrapper(*args, **kwargs):
warn(
"`Redditor.subreddit` is no longer a dict and is now an `UserSubreddit`"
f" object. Using `{func.__name__}` is deprecated and will be removed in"
"'Redditor.subreddit' is no longer a dict and is now an UserSubreddit"
f" object. Using '{func.__name__}' is deprecated and will be removed in"
" Async PRAW 8.",
category=DeprecationWarning,
stacklevel=2,
Expand All @@ -117,9 +117,9 @@ def mod(self) -> "asyncpraw.models.reddit.user_subreddit.UserSubredditModeration
return UserSubredditModeration(self)

def __getitem__(self, item):
"""Show deprecation notice for dict method `__getitem__`."""
"""Show deprecation notice for dict method ``__getitem__``."""
warn(
"`Redditor.subreddit` is no longer a dict and is now an `UserSubreddit`"
"'Redditor.subreddit' is no longer a dict and is now an UserSubreddit"
" object. Accessing attributes using string indices is deprecated.",
category=DeprecationWarning,
stacklevel=2,
Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/reddit/widgets.py
Expand Up @@ -334,7 +334,7 @@ async def refresh(self):
await self._fetch()

def __getattr__(self, attr: str) -> Any:
"""Return the value of `attr`."""
"""Return the value of ``attr``."""
if not attr.startswith("_") and not self._fetched:
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {attr!r}, did you"
Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/subreddits.py
Expand Up @@ -36,7 +36,7 @@ def default(
def gold(self, **generator_kwargs) -> AsyncIterator["asyncpraw.models.Subreddit"]:
"""Alias for :meth:`.premium` to maintain backwards compatibility."""
warn(
"`subreddits.gold` has be renamed to `subreddits.premium`.",
"'subreddits.gold' has be renamed to 'subreddits.premium'.",
category=DeprecationWarning,
stacklevel=2,
)
Expand Down

0 comments on commit 3bb04b0

Please sign in to comment.