Skip to content

Commit

Permalink
Merge 79ff1b4 into 4c218ff
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Jul 16, 2020
2 parents 4c218ff + 79ff1b4 commit aa8cb7a
Show file tree
Hide file tree
Showing 25 changed files with 180 additions and 111 deletions.
23 changes: 11 additions & 12 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ participating in this project you agree to abide by its terms.

## Responding to Issues

One of the simplest ways to help with PRAW is by answering others'
One of the simplest ways to help with Async PRAW is by answering others'
questions. When responding, always be positive. While something may be obvious
to you, it likely is not to the person asking the question.

Expand All @@ -32,24 +32,24 @@ to you, it likely is not to the person asking the question.
commenting on the issue. This act will hopefully minimize any duplicate
work.

0. Prior to creating a pull request run the `pre_push.py` script. This script
depends on the tools `black` `flake8`, `pylint`, `pydocstyle`, `sphinx` and `sphinx_rtd_theme`. They can
be installed via `pip install black flake8 pydocstyle pylint sphinx sphinx_rtd_theme` or via
1. Prior to creating a pull request run the `pre_push.py` script. This script
depends on the tools `black` `flake8`, `pylint`, `pydocstyle`, `sphinx`, `sphinx_rtd_theme`, and `sphinxcontrib-trio`. They can
be installed via `pip install black flake8 pydocstyle pylint sphinx sphinx_rtd_theme sphinxcontrib-trio` or via
`pip install asyncpraw[lint]`.

0. Add yourself as a contributor to the ``AUTHORS.rst``.
2. Add yourself as a contributor to the ``AUTHORS.rst``.

0. Once pushed, ensure that your Github Actions build succeeds. Actions will error
3. Once pushed, ensure that your Github Actions build succeeds. Actions will error
before running any tests if there are _any_ `flake8` or `pydocstyle`
issues. Resolve any issues by updating your pull request.

0. Ensure that your change has complete test coverage. Tests on methods that do
4. Ensure that your change has complete test coverage. Tests on methods that do
not require fetching data from Reddit, e.g., method argument validation,
should be saved as a unit test. Tests that hit Reddit's servers should be an
integration test and all network activity should be recorded via Betamax.
integration test and all network activity should be recorded via vcrpy.
The required packages can be installed with `pip install asyncpraw[test]`.

0. Feel free to check on the status of your pull request periodically by adding
5. Feel free to check on the status of your pull request periodically by adding
a comment.

## Becoming a Team Member
Expand All @@ -61,7 +61,7 @@ we would like to see you push a number of contributions before we add you on.

## Style Recommendations

To keep PRAW's source consistent, all contribution code must pass the
To keep Async PRAW's source consistent, all contribution code must pass the
`pre_push.py` script. Github Actions will enforce the passing of the automated
tests, as well as style checking done via the `pre_push.py` script. While this
script helps ensure consistency with much of PEP8 and PEP257 there are a few
Expand Down Expand Up @@ -90,8 +90,7 @@ from os.path import abspath, join
import sys
import traceback

from prawcore import NotFound
import requests
from asyncprawcore import NotFound

from ...const import API_PATH
from ..listing.mixins import SubmissionListingMixin
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Steps to reproduce the behavior:
<!-- include your code, without the Reddit() initialization, so as to not leak private credentials. -->

**System Info**
- OS:
- Python:
- PRAW Version:
- OS:
- Python:
- Async PRAW Version:
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

7.1.0 (2020/07/15)
------------------

* Initial Async PRAW Release.


For changes in PRAW please see: `PRAW Changelog
<https://praw.readthedocs.io/en/latest/pages/changelog.html>`_
3 changes: 1 addition & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at bbzbryce@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at lilspazjoekp@gmail.com. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

Expand Down Expand Up @@ -82,4 +82,3 @@ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcem

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

9 changes: 0 additions & 9 deletions asyncpraw/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class Config:
"extended": configparser.ExtendedInterpolation,
}

@staticmethod
def _config_boolean(item):
if isinstance(item, bool):
return item
return item.lower() in {"1", "yes", "true", "on"}

@classmethod
def _load_config(cls, config_interpolation: Optional[str] = None):
"""Attempt to load settings from various praw.ini files."""
Expand Down Expand Up @@ -107,9 +101,6 @@ def _fetch_or_not_set(self, key):

def _initialize_attributes(self):
self._short_url = self._fetch_default("short_url") or self.CONFIG_NOT_SET
self.check_for_updates = self._config_boolean(
self._fetch_or_not_set("check_for_updates")
)
self.kinds = {
x: self._fetch("{}_kind".format(x))
for x in [
Expand Down
1 change: 0 additions & 1 deletion asyncpraw/models/reddit/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ async def update(
}

url = API_PATH["live_update_thread"].format(id=self.thread.id)
# prawcore (0.7.0) Session.request() modifies `data` kwarg
await self.thread._reddit.post(url, data=data.copy())
self.thread._reset_attributes(*data.keys())

Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/reddit/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ async def sticky(self, state: bool = True, bottom: bool = True):
.. note:: When a submission is stickied two or more times, the Reddit
API responds with a 409 error that is raises as a ``Conflict`` by
PRAWCore. The method suppresses these ``Conflict`` errors.
asyncprawcore. The method suppresses these ``Conflict`` errors.
This submission will replace the second stickied submission if one
exists.
Expand Down
12 changes: 6 additions & 6 deletions asyncpraw/models/reddit/subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3416,7 +3416,7 @@ async def upload_banner(self, image_path):
:param image_path: A path to a jpeg or png image.
Raises ``prawcore.TooLarge`` if the overall request body is too large.
Raises ``asyncprawcore.TooLarge`` if the overall request body is too large.
Raises :class:`.RedditAPIException` if there are other issues with the
uploaded image. Unfortunately the exception info might not be very
Expand All @@ -3442,7 +3442,7 @@ async def upload_banner_additional_image(self, image_path, align=None):
:param align: Either ``left``, ``centered``, or ``right``. (default:
``left``).
Raises ``prawcore.TooLarge`` if the overall request body is too large.
Raises ``asyncprawcore.TooLarge`` if the overall request body is too large.
Raises :class:`.RedditAPIException` if there are other issues with the
uploaded image. Unfortunately the exception info might not be very
Expand Down Expand Up @@ -3479,7 +3479,7 @@ async def upload_banner_hover_image(self, image_path):
Fails if the Subreddit does not have an additional image defined
Raises ``prawcore.TooLarge`` if the overall request body is too large.
Raises ``asyncprawcore.TooLarge`` if the overall request body is too large.
Raises :class:`.RedditAPIException` if there are other issues with the
uploaded image. Unfortunately the exception info might not be very
Expand All @@ -3505,7 +3505,7 @@ async def upload_header(self, image_path):
:returns: A dictionary containing a link to the uploaded image under
the key ``img_src``.
Raises ``prawcore.TooLarge`` if the overall request body is too large.
Raises ``asyncprawcore.TooLarge`` if the overall request body is too large.
Raises :class:`.RedditAPIException` if there are other issues with the
uploaded image. Unfortunately the exception info might not be very
Expand All @@ -3529,7 +3529,7 @@ async def upload_mobile_header(self, image_path):
:returns: A dictionary containing a link to the uploaded image under
the key ``img_src``.
Raises ``prawcore.TooLarge`` if the overall request body is too large.
Raises ``asyncprawcore.TooLarge`` if the overall request body is too large.
Raises :class:`.RedditAPIException` if there are other issues with the
uploaded image. Unfortunately the exception info might not be very
Expand All @@ -3553,7 +3553,7 @@ async def upload_mobile_icon(self, image_path):
:returns: A dictionary containing a link to the uploaded image under
the key ``img_src``.
Raises ``prawcore.TooLarge`` if the overall request body is too large.
Raises ``asyncprawcore.TooLarge`` if the overall request body is too large.
Raises :class:`.RedditAPIException` if there are other issues with the
uploaded image. Unfortunately the exception info might not be very
Expand Down
2 changes: 0 additions & 2 deletions asyncpraw/praw.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[DEFAULT]
# A boolean to indicate whether or not to check for package updates.
check_for_updates=True

# Object to kind mappings
comment_kind=t1
Expand Down
32 changes: 8 additions & 24 deletions asyncpraw/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,14 @@

from . import models
from .config import Config
from .const import API_PATH, USER_AGENT_FORMAT, __version__
from .const import API_PATH, USER_AGENT_FORMAT
from .exceptions import (
ClientException,
MissingRequiredAttributeException,
RedditAPIException,
)
from .objector import Objector

try:
from update_checker import update_check

UPDATE_CHECKER_MISSING = False
except ImportError: # pragma: no cover
UPDATE_CHECKER_MISSING = True


Comment = models.Comment
Redditor = models.Redditor
Expand All @@ -63,7 +56,6 @@ class Reddit:
"""

update_checked = False
_ratelimit_regex = re.compile(r"([0-9]{1,2}) (seconds?|minutes?)")

@property
Expand Down Expand Up @@ -146,7 +138,7 @@ def __init__(
variable praw_site. If it is not found there, the DEFAULT site will
be used.
:param requestor_class: A class that will be used to create a
requestor. If not set, use ``prawcore.Requestor`` (default: None).
requestor. If not set, use ``asyncprawcore.Requestor`` (default: None).
:param requestor_kwargs: Dictionary with additional keyword arguments
used to initialize the requestor (default: None).
Expand Down Expand Up @@ -228,9 +220,8 @@ async def request(self, *args, **kwargs):
"to the `Reddit` class constructor."
)

self._check_for_update()
self._prepare_objector()
self._prepare_prawcore(requestor_class, requestor_kwargs)
self._prepare_asyncprawcore(requestor_class, requestor_kwargs)

self.auth = models.Auth(self, None)
"""An instance of :class:`.Auth`.
Expand Down Expand Up @@ -370,13 +361,6 @@ async def request(self, *args, **kwargs):
"""

def _check_for_update(self):
if UPDATE_CHECKER_MISSING:
return
if not Reddit.update_checked and self.config.check_for_updates:
update_check(__package__, __version__)
Reddit.update_checked = True

def _prepare_objector(self):
mappings = {
self.config.kinds["comment"]: models.Comment,
Expand Down Expand Up @@ -418,7 +402,7 @@ def _prepare_objector(self):
}
self._objector = Objector(self, mappings)

def _prepare_prawcore(self, requestor_class=None, requestor_kwargs=None):
def _prepare_asyncprawcore(self, requestor_class=None, requestor_kwargs=None):
requestor_class = requestor_class or Requestor
requestor_kwargs = requestor_kwargs or {}

Expand All @@ -430,11 +414,11 @@ def _prepare_prawcore(self, requestor_class=None, requestor_kwargs=None):
)

if self.config.client_secret:
self._prepare_trusted_prawcore(requestor)
self._prepare_trusted_asyncprawcore(requestor)
else:
self._prepare_untrusted_prawcore(requestor)
self._prepare_untrusted_asyncprawcore(requestor)

def _prepare_trusted_prawcore(self, requestor):
def _prepare_trusted_asyncprawcore(self, requestor):
authenticator = TrustedAuthenticator(
requestor,
self.config.client_id,
Expand All @@ -455,7 +439,7 @@ def _prepare_trusted_prawcore(self, requestor):
else:
self._core = self._read_only_core

def _prepare_untrusted_prawcore(self, requestor):
def _prepare_untrusted_asyncprawcore(self, requestor):
authenticator = UntrustedAuthenticator(
requestor, self.config.client_id, self.config.redirect_uri
)
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
from asyncpraw import __version__


copyright = "2020, Bryce Boe"
copyright = "2020, Joel Payne"
exclude_patterns = ["_build"]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinxcontrib_trio"]
html_static_path = ["_static"]
html_theme = "sphinx_rtd_theme"
html_theme_options = {"collapse_navigation": True}
htmlhelp_basename = "PRAW"
htmlhelp_basename = "Async PRAW"
intersphinx_mapping = {"python": ("https://docs.python.org/3.8", None)}
master_doc = "index"
nitpicky = True
project = "PRAW"
project = "Async PRAW"
pygments_style = "sphinx"
release = __version__
source_suffix = ".rst"
Expand Down
4 changes: 4 additions & 0 deletions docs/getting_started/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Configuring Async PRAW
======================

.. note::

Async PRAW is fully compatible with the configuration system that PRAW uses.

.. toctree::
:maxdepth: 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Async PRAW Environment Variables
================================

Async PRAW uses the same environment variables as PRAW.
The second-highest priority configuration options can be passed to a program
via environment variables prefixed with ``praw_``.

Expand Down
8 changes: 4 additions & 4 deletions docs/getting_started/configuration/reddit_initialization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Keyword Arguments to :class:`.Reddit`
=====================================

Most of Async PRAW's documentation will demonstrate configuring Async PRAW through the use
of keyword arguments when initializing instances of :class:`.Reddit`. All of
the :ref:`configuration_options` can be specified using a keyword argument of
the same name.
Most of Async PRAW's documentation will demonstrate configuring Async PRAW
through the use of keyword arguments when initializing instances of
:class:`.Reddit`. All of the :ref:`configuration_options` can be specified
using a keyword argument of the same name.

For example, if we wanted to explicitly pass the information for ``bot3``
defined in :ref:`the praw.ini custom site example <custom_site_example>`
Expand Down
20 changes: 15 additions & 5 deletions docs/getting_started/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ Frequently Asked Questions

Q: How can I refresh a comment/subreddit/submission?

A: Directly calling the constructors will refresh the value:
A: There is two ways to do this:

.. code-block:: python
* Directly calling the constructors will refresh the value:

.. code-block:: python
await reddit.comment(id=comment.id)
await reddit.subreddit(display_name=subreddit.display_name)
await reddit.submission(id=submission.id)
* Calling :meth:`~.RedditBase.load`:

.. code-block:: python
await reddit.comment(id=comment.id)
await reddit.subreddit(display_name=subreddit.display_name)
await reddit.submission(id=submission.id)
await comment.load()
await subreddit.load()
await submission.load()
.. _faq2:

Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ part of the installation command:

.. code-block:: bash
pip install asyncpraw==7.0.0
pip install asyncpraw==7.1.0
Installing the Latest Development Version
-----------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ applications and **web** applications.
package_info/change_log
package_info/contributing
package_info/glossary
package_info/asyncpraw_migration
package_info/praw7_migration
package_info/references

Expand Down
Loading

0 comments on commit aa8cb7a

Please sign in to comment.