diff --git a/asyncpraw/config.py b/asyncpraw/config.py index 1641558d..cfe7ced9 100644 --- a/asyncpraw/config.py +++ b/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 diff --git a/asyncpraw/exceptions.py b/asyncpraw/exceptions.py index 3c6bd8be..68e12668 100644 --- a/asyncpraw/exceptions.py +++ b/asyncpraw/exceptions.py @@ -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.", @@ -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?" ) @@ -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." ) @@ -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, diff --git a/asyncpraw/models/helpers.py b/asyncpraw/models/helpers.py index 4513be82..79313b39 100644 --- a/asyncpraw/models/helpers.py +++ b/asyncpraw/models/helpers.py @@ -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) @@ -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( diff --git a/asyncpraw/models/list/trophy.py b/asyncpraw/models/list/trophy.py index 67d22c36..cd0ee236 100644 --- a/asyncpraw/models/list/trophy.py +++ b/asyncpraw/models/list/trophy.py @@ -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. """ diff --git a/asyncpraw/models/listing/mixins/base.py b/asyncpraw/models/listing/mixins/base.py index 3bbab050..9981efa8 100644 --- a/asyncpraw/models/listing/mixins/base.py +++ b/asyncpraw/models/listing/mixins/base.py @@ -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.""" diff --git a/asyncpraw/models/mod_notes.py b/asyncpraw/models/mod_notes.py index d79ba755..a70e7b02 100644 --- a/asyncpraw/models/mod_notes.py +++ b/asyncpraw/models/mod_notes.py @@ -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 = { @@ -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() @@ -423,7 +423,7 @@ 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 ( @@ -431,9 +431,9 @@ def __call__( 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 = [] diff --git a/asyncpraw/models/reddit/collections.py b/asyncpraw/models/reddit/collections.py index bb4c5927..2774d530 100644 --- a/asyncpraw/models/reddit/collections.py +++ b/asyncpraw/models/reddit/collections.py @@ -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: @@ -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 diff --git a/asyncpraw/models/reddit/comment.py b/asyncpraw/models/reddit/comment.py index baf49322..2b66149f 100644 --- a/asyncpraw/models/reddit/comment.py +++ b/asyncpraw/models/reddit/comment.py @@ -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 @@ -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")] diff --git a/asyncpraw/models/reddit/draft.py b/asyncpraw/models/reddit/draft.py index 4db99a5f..eb66cc0e 100644 --- a/asyncpraw/models/reddit/draft.py +++ b/asyncpraw/models/reddit/draft.py @@ -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 @@ -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), diff --git a/asyncpraw/models/reddit/live.py b/asyncpraw/models/reddit/live.py index f2a2c5e3..e56d4c6b 100644 --- a/asyncpraw/models/reddit/live.py +++ b/asyncpraw/models/reddit/live.py @@ -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) @@ -591,7 +591,7 @@ 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 @@ -599,7 +599,7 @@ async def update( .. 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) """ @@ -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): diff --git a/asyncpraw/models/reddit/mixins/gildable.py b/asyncpraw/models/reddit/mixins/gildable.py index 6ab9fb9e..8f02d22e 100644 --- a/asyncpraw/models/reddit/mixins/gildable.py +++ b/asyncpraw/models/reddit/mixins/gildable.py @@ -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, ) diff --git a/asyncpraw/models/reddit/modmail.py b/asyncpraw/models/reddit/modmail.py index 36b1dabc..a3580f09 100644 --- a/asyncpraw/models/reddit/modmail.py +++ b/asyncpraw/models/reddit/modmail.py @@ -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 diff --git a/asyncpraw/models/reddit/redditor.py b/asyncpraw/models/reddit/redditor.py index b35ec3dc..99502d12 100644 --- a/asyncpraw/models/reddit/redditor.py +++ b/asyncpraw/models/reddit/redditor.py @@ -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 ( diff --git a/asyncpraw/models/reddit/removal_reasons.py b/asyncpraw/models/reddit/removal_reasons.py index 49a8f605..92cc42cf 100644 --- a/asyncpraw/models/reddit/removal_reasons.py +++ b/asyncpraw/models/reddit/removal_reasons.py @@ -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, ) diff --git a/asyncpraw/models/reddit/submission.py b/asyncpraw/models/reddit/submission.py index 4613c8e7..158612b3 100644 --- a/asyncpraw/models/reddit/submission.py +++ b/asyncpraw/models/reddit/submission.py @@ -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`` diff --git a/asyncpraw/models/reddit/subreddit.py b/asyncpraw/models/reddit/subreddit.py index 7c4243ca..a85965cf 100644 --- a/asyncpraw/models/reddit/subreddit.py +++ b/asyncpraw/models/reddit/subreddit.py @@ -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) @@ -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. @@ -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), @@ -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: @@ -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, @@ -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 diff --git a/asyncpraw/models/reddit/user_subreddit.py b/asyncpraw/models/reddit/user_subreddit.py index 6b58e525..a3c64abe 100644 --- a/asyncpraw/models/reddit/user_subreddit.py +++ b/asyncpraw/models/reddit/user_subreddit.py @@ -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, @@ -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, diff --git a/asyncpraw/models/reddit/widgets.py b/asyncpraw/models/reddit/widgets.py index 76a9f216..015acef5 100755 --- a/asyncpraw/models/reddit/widgets.py +++ b/asyncpraw/models/reddit/widgets.py @@ -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" diff --git a/asyncpraw/models/subreddits.py b/asyncpraw/models/subreddits.py index e3be396a..22fe5f2b 100644 --- a/asyncpraw/models/subreddits.py +++ b/asyncpraw/models/subreddits.py @@ -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, ) diff --git a/asyncpraw/models/user.py b/asyncpraw/models/user.py index 3ff04348..c4fb1e79 100644 --- a/asyncpraw/models/user.py +++ b/asyncpraw/models/user.py @@ -157,8 +157,8 @@ async def me( if self._reddit.read_only: if not self._reddit.config.custom.get("praw8_raise_exception_on_me"): warn( - "The `None` return value is deprecated, and will raise a" - " `ReadOnlyException` beginning with Async PRAW 8. See" + "The 'None' return value is deprecated, and will raise a" + " ReadOnlyException beginning with Async PRAW 8. See" " documentation for forward compatibility options.", category=DeprecationWarning, stacklevel=2, diff --git a/asyncpraw/reddit.py b/asyncpraw/reddit.py index dbb2e256..bfff4a29 100644 --- a/asyncpraw/reddit.py +++ b/asyncpraw/reddit.py @@ -305,7 +305,7 @@ async def request(self, *args, **kwargs): required_message = ( "Required configuration setting {!r} missing. \nThis setting can be" - " provided in a praw.ini file, as a keyword argument to the `Reddit` class" + " provided in a praw.ini file, as a keyword argument to the Reddit class" " constructor, or as an environment variable." ) for attribute in ("client_id", "user_agent"): @@ -317,7 +317,7 @@ async def request(self, *args, **kwargs): raise MissingRequiredAttributeException( f"{required_message.format('client_secret')}\nFor installed" " applications this value must be set to None via a keyword argument" - " to the `Reddit` class constructor." + " to the Reddit class constructor." ) self._check_for_update() self._prepare_objector() @@ -535,8 +535,8 @@ def _prepare_common_authorizer(self, authenticator): ) if self.config.refresh_token: raise TypeError( - "``refresh_token`` setting cannot be provided when providing" - " ``token_manager``" + "'refresh_token' setting cannot be provided when providing" + " 'token_manager'" ) self._token_manager.reddit = self @@ -750,7 +750,7 @@ def info( none_count = (fullnames, url, subreddits).count(None) if none_count != 2: raise TypeError( - "Either `fullnames`, `url`, or `subreddits` must be provided." + "Either 'fullnames', 'url', or 'subreddits' must be provided." ) is_using_fullnames = fullnames is not None @@ -759,7 +759,7 @@ def info( if ids_or_names is not None: if isinstance(ids_or_names, str): raise TypeError( - "`fullnames` and `subreddits` must be a non-str iterable." + "'fullnames' and 'subreddits' must be a non-str iterable." ) api_parameter_name = "id" if is_using_fullnames else "sr_name" @@ -1027,7 +1027,7 @@ async def request( """ if data and json: - raise ClientException("At most one of `data` or `json` is supported.") + raise ClientException("At most one of 'data' or 'json' is supported.") try: return await self._core.request( data=data, diff --git a/asyncpraw/util/cache.py b/asyncpraw/util/cache.py index 98618202..469ee815 100644 --- a/asyncpraw/util/cache.py +++ b/asyncpraw/util/cache.py @@ -5,15 +5,15 @@ class cachedproperty: """A decorator for caching a property's result. - Similar to `property`, but the wrapped method's result is cached on the instance. - This is achieved by setting an entry in the object's instance dictionary with the - same name as the property. When the name is later accessed, the value in the - instance dictionary takes precedence over the (non-data descriptor) property. + Similar to :py:class:`property`, but the wrapped method's result is cached on the + instance. This is achieved by setting an entry in the object's instance dictionary + with the same name as the property. When the name is later accessed, the value in + the instance dictionary takes precedence over the (non-data descriptor) property. This is useful for implementing lazy-loaded properties. - The cache can be invalidated via `delattr()`, or by modifying `__dict__` directly. - It will be repopulated on next access. + The cache can be invalidated via :py:meth:`delattr`, or by modifying ``__dict__`` + directly. It will be repopulated on next access. .. versionadded:: 6.3.0 diff --git a/asyncpraw/util/snake.py b/asyncpraw/util/snake.py index 4f5dcdbf..4873291a 100644 --- a/asyncpraw/util/snake.py +++ b/asyncpraw/util/snake.py @@ -7,7 +7,7 @@ def camel_to_snake(name: str) -> str: - """Convert `name` from camelCase to snake_case.""" + """Convert ``name`` from camelCase to snake_case.""" return _re_camel_to_snake.sub(r"\1_", name).lower() diff --git a/asyncpraw/util/token_manager.py b/asyncpraw/util/token_manager.py index 886d3186..e0e69a08 100644 --- a/asyncpraw/util/token_manager.py +++ b/asyncpraw/util/token_manager.py @@ -35,7 +35,7 @@ def reddit(self): def reddit(self, value): if self._reddit is not None: raise RuntimeError( - "``reddit`` can only be set once and is done automatically" + "'reddit' can only be set once and is done automatically" ) self._reddit = value diff --git a/docs/examples/obtain_refresh_token.py b/docs/examples/obtain_refresh_token.py index 706b1dcb..1fca2d2b 100755 --- a/docs/examples/obtain_refresh_token.py +++ b/docs/examples/obtain_refresh_token.py @@ -36,7 +36,7 @@ async def main(): """Provide the program's entry point when directly executed.""" scope_input = input( - "Enter a comma separated list of scopes, or `*` for all scopes: " + "Enter a comma separated list of scopes, or '*' for all scopes: " ) scopes = [scope.strip() for scope in scope_input.strip().split(",")] diff --git a/docs/examples/use_file_token_manager.py b/docs/examples/use_file_token_manager.py index 1a527ba5..d159eccc 100755 --- a/docs/examples/use_file_token_manager.py +++ b/docs/examples/use_file_token_manager.py @@ -2,11 +2,11 @@ """This example demonstrates using the file token manager for refresh tokens. In order to run this program, you will first need to obtain a valid refresh token. You -can use the `obtain_refresh_token.py` example to help. +can use the ``obtain_refresh_token.py`` example to help. -In this example, refresh tokens will be saved into a file `refresh_token.txt` relative +In this example, refresh tokens will be saved into a file ``refresh_token.txt`` relative to your current working directory. If your current working directory is under version -control it is strongly encouraged you add `refresh_token.txt` to the version control +control it is strongly encouraged you add ``refresh_token.txt`` to the version control ignore list. Usage: @@ -39,12 +39,10 @@ async def initialize_refresh_token_file(): async def main(): if "praw_client_id" not in os.environ: - sys.stderr.write("Environment variable ``praw_client_id`` must be defined\n") + sys.stderr.write("Environment variable 'praw_client_id' must be defined\n") return 1 if "praw_client_secret" not in os.environ: - sys.stderr.write( - "Environment variable ``praw_client_secret`` must be defined\n" - ) + sys.stderr.write("Environment variable 'praw_client_secret' must be defined\n") return 1 await initialize_refresh_token_file() diff --git a/docs/examples/use_sqlite_token_manager.py b/docs/examples/use_sqlite_token_manager.py index ea36eaf4..c2606a6b 100755 --- a/docs/examples/use_sqlite_token_manager.py +++ b/docs/examples/use_sqlite_token_manager.py @@ -34,16 +34,14 @@ async def main(): if "praw_client_id" not in os.environ: - sys.stderr.write("Environment variable ``praw_client_id`` must be defined\n") + sys.stderr.write("Environment variable 'praw_client_id' must be defined\n") return 1 if "praw_client_secret" not in os.environ: - sys.stderr.write( - "Environment variable ``praw_client_secret`` must be defined\n" - ) + sys.stderr.write("Environment variable 'praw_client_secret' must be defined\n") return 1 if len(sys.argv) != 2: sys.stderr.write( - "KEY must be provided.\n\nUsage: python3 use_sqlite_token_manager.py" + "'KEY' must be provided.\n\nUsage: python3 use_sqlite_token_manager.py" " TOKEN_KEY\n" ) return 1 diff --git a/setup.py b/setup.py index 1701015b..cb45b415 100644 --- a/setup.py +++ b/setup.py @@ -59,7 +59,7 @@ "Topic :: Utilities", ], description=( - "Async PRAW, an abbreviation for `Asynchronous Python Reddit API Wrapper`, is a" + 'Async PRAW, an abbreviation for "Asynchronous Python Reddit API Wrapper", is a' " python package that allows for simple access to Reddit's API." ), extras_require=extras, diff --git a/tests/unit/models/reddit/test_comment.py b/tests/unit/models/reddit/test_comment.py index 2263588c..9c0ed86a 100644 --- a/tests/unit/models/reddit/test_comment.py +++ b/tests/unit/models/reddit/test_comment.py @@ -25,7 +25,7 @@ def test_equality(self, reddit): assert comment2 == "dummy1" def test_construct_failure(self, reddit): - message = "Exactly one of `id`, `url`, or `_data` must be provided." + message = "Exactly one of 'id', 'url', or '_data' must be provided." with pytest.raises(TypeError) as excinfo: Comment(reddit) assert str(excinfo.value) == message diff --git a/tests/unit/models/reddit/test_draft.py b/tests/unit/models/reddit/test_draft.py index e39cab56..ca4168e7 100644 --- a/tests/unit/models/reddit/test_draft.py +++ b/tests/unit/models/reddit/test_draft.py @@ -7,7 +7,7 @@ class TestDraft(UnitTest): def test_construct_failure(self, reddit): - message = "Exactly one of `id` or `_data` must be provided." + message = "Exactly one of 'id' or '_data' must be provided." with pytest.raises(TypeError) as excinfo: Draft(reddit) assert str(excinfo.value) == message @@ -24,7 +24,7 @@ async def test_create_failure(self, reddit): with pytest.raises(TypeError) as excinfo: await reddit.drafts.create(url="url", selftext="selftext") assert ( - str(excinfo.value) == "Exactly one of `selftext` or `url` must be provided." + str(excinfo.value) == "Exactly one of 'selftext' or 'url' must be provided." ) def test_equality(self, reddit): @@ -116,5 +116,5 @@ async def test_submit_failure(self, reddit): await draft.submit() assert ( str(excinfo.value) - == "`subreddit` must be set on the Draft or passed as a keyword argument." + == "'subreddit' must be set on the Draft or passed as a keyword argument." ) diff --git a/tests/unit/models/reddit/test_live.py b/tests/unit/models/reddit/test_live.py index 1ad0a29e..079c65c1 100644 --- a/tests/unit/models/reddit/test_live.py +++ b/tests/unit/models/reddit/test_live.py @@ -24,7 +24,7 @@ def test_construct_success(self, reddit): assert thread.id == thread_id def test_construct_failure(self, reddit): - message = "Either `id` or `_data` must be provided." + message = "Either 'id' or '_data' must be provided." with pytest.raises(TypeError) as excinfo: LiveThread(reddit) assert str(excinfo.value) == message @@ -118,7 +118,7 @@ def test_construct_success(self, reddit): assert update._fetched def test_construct_failure(self, reddit): - message = "Either `thread_id` and `update_id`, or `_data` must be provided." + message = "Either 'thread_id' and 'update_id', or '_data' must be provided." thread_id = "dummy_thread_id" update_id = "dummy_update_id" diff --git a/tests/unit/models/reddit/test_modmail.py b/tests/unit/models/reddit/test_modmail.py index d82710b9..adc21d35 100644 --- a/tests/unit/models/reddit/test_modmail.py +++ b/tests/unit/models/reddit/test_modmail.py @@ -7,7 +7,7 @@ class TestModmailConversation(UnitTest): def test_construct_failure(self, reddit): - message = "Either `id` or `_data` must be provided." + message = "Either 'id' or '_data' must be provided." with pytest.raises(TypeError) as excinfo: ModmailConversation(reddit) assert str(excinfo.value) == message diff --git a/tests/unit/models/reddit/test_redditor.py b/tests/unit/models/reddit/test_redditor.py index d11ae935..37523aff 100644 --- a/tests/unit/models/reddit/test_redditor.py +++ b/tests/unit/models/reddit/test_redditor.py @@ -20,7 +20,7 @@ def test_equality(self, reddit): assert redditor2 == "dummy1" def test_construct_failure(self, reddit): - message = "Exactly one of `name`, `fullname`, or `_data` must be provided." + message = "Exactly one of 'name', 'fullname', or '_data' must be provided." with pytest.raises(TypeError) as excinfo: Redditor(reddit) assert str(excinfo.value) == message diff --git a/tests/unit/models/reddit/test_submission.py b/tests/unit/models/reddit/test_submission.py index 954625bd..0a82116c 100644 --- a/tests/unit/models/reddit/test_submission.py +++ b/tests/unit/models/reddit/test_submission.py @@ -21,7 +21,7 @@ def test_equality(self, reddit): assert submission2 == "dummy1" def test_construct_failure(self, reddit): - message = "Exactly one of `id`, `url`, or `_data` must be provided." + message = "Exactly one of 'id', 'url', or '_data' must be provided." with pytest.raises(TypeError) as excinfo: Submission(reddit) assert str(excinfo.value) == message diff --git a/tests/unit/models/reddit/test_subreddit.py b/tests/unit/models/reddit/test_subreddit.py index 31c2b375..a6aa29fc 100644 --- a/tests/unit/models/reddit/test_subreddit.py +++ b/tests/unit/models/reddit/test_subreddit.py @@ -32,7 +32,7 @@ def test_equality(self, reddit): assert subreddit2 == "dummy1" def test_construct_failure(self, reddit): - message = "Either `display_name` or `_data` must be provided." + message = "Either 'display_name' or '_data' must be provided." with pytest.raises(TypeError) as excinfo: Subreddit(reddit) assert str(excinfo.value) == message @@ -115,8 +115,8 @@ async def test_notes_delete__invalid_args(self): with pytest.raises(TypeError) as excinfo: await Subreddit(None, "SubTestBot1").mod.notes.delete(note_id="111") assert excinfo.value.args[0] == ( - "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')." ) def test_repr(self, reddit): @@ -135,7 +135,7 @@ def test_str(self, reddit): assert str(subreddit) == "name" async def test_submit_failure(self, reddit): - message = "Either `selftext` or `url` must be provided." + message = "Either 'selftext' or 'url' must be provided." subreddit = Subreddit(reddit, display_name="name") with pytest.raises(TypeError) as excinfo: diff --git a/tests/unit/models/test_mod_notes.py b/tests/unit/models/test_mod_notes.py index 0858976a..beae46e7 100644 --- a/tests/unit/models/test_mod_notes.py +++ b/tests/unit/models/test_mod_notes.py @@ -20,7 +20,7 @@ async def test_notes_delete__missing_note_id(self): await Subreddit(None, "a").mod.notes.delete(redditor="redditor") assert ( excinfo.value.args[0] - == "Either `note_id` or `delete_all` must be provided." + == "Either 'note_id' or 'delete_all' must be provided." ) @@ -38,7 +38,7 @@ def test__call__missing_arguments(self, reddit): reddit.notes() assert ( excinfo.value.args[0] - == "Either the `pairs`, `redditors`, `subreddits`, or `things` parameters must be provided." + == "Either the 'pairs', 'redditors', 'subreddits', or 'things' parameters must be provided." ) def test__call__redditors_missing_subreddits(self, reddit): @@ -46,7 +46,7 @@ def test__call__redditors_missing_subreddits(self, reddit): reddit.notes(subreddits=[1]) assert ( excinfo.value.args[0] - == "`redditors` must be non-empty if `subreddits` is not empty." + == "'redditors' must be non-empty if 'subreddits' is not empty." ) diff --git a/tests/unit/test_deprecations.py b/tests/unit/test_deprecations.py index c34eecf5..7d10e5c8 100644 --- a/tests/unit/test_deprecations.py +++ b/tests/unit/test_deprecations.py @@ -50,14 +50,14 @@ async def test_gild_method(self, reddit): with pytest.raises(DeprecationWarning) as excinfo: submission = await reddit.submission("1234", fetch=False) await submission.gild() - assert excinfo.value.args[0] == "`.gild` has been renamed to `.award`." + assert excinfo.value.args[0] == "'.gild' has been renamed to '.award'." def test_gold_method(self, reddit): with pytest.raises(DeprecationWarning) as excinfo: reddit.subreddits.gold() assert ( excinfo.value.args[0] - == "`subreddits.gold` has be renamed to `subreddits.premium`." + == "'subreddits.gold' has be renamed to 'subreddits.premium'." ) async def test_lazy_argument_rename(self, reddit): @@ -137,16 +137,16 @@ def test_user_subreddit_as_dict(self): assert display_name == "test" assert ( warning_info.list[0].message.args[0] - == "`Redditor.subreddit` is no longer a dict and is now an" - " `UserSubreddit` object. Accessing attributes using string indices is" + == "'Redditor.subreddit' is no longer a dict and is now an" + " UserSubreddit object. Accessing attributes using string indices is" " deprecated." ) assert user_subreddit.keys() == user_subreddit.__dict__.keys() assert ( warning_info.list[1].message.args[0] - == "`Redditor.subreddit` is no longer a dict and is now an" - " `UserSubreddit` object. Using `keys` is deprecated and will be" - " removed in Async PRAW 8." + == "'Redditor.subreddit' is no longer a dict and is now an" + " UserSubreddit object. Using 'keys' is deprecated and will be removed" + " in Async PRAW 8." ) def test_validate_on_submit(self, reddit): @@ -164,7 +164,7 @@ def test_web_socket_exception_attribute(self): _ = exc.original_exception assert ( excinfo.value.args[0] - == "Accessing the attribute original_exception is deprecated. Please" + == "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." ) diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py index eb62bfd1..53c58918 100644 --- a/tests/unit/test_exceptions.py +++ b/tests/unit/test_exceptions.py @@ -114,7 +114,7 @@ def test_message(self): assert ( str(DuplicateReplaceException()) == "A duplicate comment has been detected. Are you attempting to call" - " ``replace_more_comments`` more than once?" + " 'replace_more_comments' more than once?" ) @@ -125,8 +125,8 @@ def test_inheritance(self): def test_str(self): assert ( str(InvalidFlairTemplateID("123")) - == "The flair template ID ``123`` is invalid. If you are trying to create a" - " flair, please use the ``add`` method." + == "The flair template ID '123' is invalid. If you are trying to create a" + " flair, please use the 'add' method." ) diff --git a/tests/unit/test_reddit.py b/tests/unit/test_reddit.py index 8c502ac6..fd89df00 100644 --- a/tests/unit/test_reddit.py +++ b/tests/unit/test_reddit.py @@ -70,8 +70,8 @@ def test_conflicting_settings(self): ) assert ( str(excinfo.value) - == "``refresh_token`` setting cannot be provided when providing" - " ``token_manager``" + == "'refresh_token' setting cannot be provided when providing" + " 'token_manager'" ) async def test_context_manager(self): @@ -84,7 +84,7 @@ def test_info__invalid_param(self, reddit): with pytest.raises(TypeError) as excinfo: reddit.info(fullnames=None) - err_str = "Either `fullnames`, `url`, or `subreddits` must be provided." + err_str = "Either 'fullnames', 'url', or 'subreddits' must be provided." assert str(excinfo.value) == err_str with pytest.raises(TypeError) as excinfo: @@ -474,7 +474,7 @@ async def test_request__json_and_body(self): data={"key": "value"}, json={"key": "value"}, method="POST", path="/" ) assert str(excinfo.value).startswith( - "At most one of `data` or `json` is supported." + "At most one of 'data' or 'json' is supported." ) async def test_submission(self, reddit): diff --git a/tests/unit/util/test_token_manager.py b/tests/unit/util/test_token_manager.py index c4cef115..82335e6c 100644 --- a/tests/unit/util/test_token_manager.py +++ b/tests/unit/util/test_token_manager.py @@ -42,7 +42,7 @@ def test_reddit__must_only_be_set_once(self): manager.reddit = None assert ( str(excinfo.value) - == "``reddit`` can only be set once and is done automatically" + == "'reddit' can only be set once and is done automatically" ) diff --git a/tools/generate_award_table.py b/tools/generate_award_table.py new file mode 100755 index 00000000..e69de29b diff --git a/tools/static_word_checks.py b/tools/static_word_checks.py index 80338243..4e3f9899 100644 --- a/tools/static_word_checks.py +++ b/tools/static_word_checks.py @@ -45,13 +45,13 @@ def check_for_double_syntax(self, filename: str, content: str) -> bool: with open(filename, "w") as fp: fp.write(newcontent) print( - f"{filename}: Replaced all instances of ``/r/`` and/or ``/u/`` to" - " ``r/`` and/or ``u/``." + f"{filename}: Replaced all instances of '/r/' and/or '/u/' to" + " 'r/' and/or 'u/'." ) return True print( - f"{filename}: This file contains instances of ``/r/`` and/or ``/u/``." - " Please change them to ``r/`` and/or ``u/``." + f"{filename}: This file contains instances of '/r/' and/or '/u/'." + " Please change them to 'r/' and/or 'u/'." ) return False @@ -67,8 +67,8 @@ def check_for_noreturn(self, filename: str, line_number: int, content: str) -> b """ if "noreturn" in content.lower(): print( - f"{filename}: Line {line_number} has phrase ``noreturn``, please edit" - " and remove this." + f"{filename}: Line {line_number} has phrase 'noreturn', please edit and" + " remove this." ) return False return True