Skip to content

Commit

Permalink
Format with black's --experimental-string-processing flag
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Nov 12, 2021
1 parent 8a5cc1d commit 35fb14b
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 29 deletions.
2 changes: 1 addition & 1 deletion asyncpraw/models/reddit/user_subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ 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"
f" Async PRAW 8.",
" Async PRAW 8.",
category=DeprecationWarning,
stacklevel=2,
)
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/use_file_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ async def main():
print(f"{await reddit.user.me()} is authenticated with all scopes")
elif "identity" in scopes:
print(
f"{await reddit.user.me()} is authenticated with the following scopes: {scopes}"
f"{await reddit.user.me()} is authenticated with the following scopes:"
f" {scopes}"
)
else:
print(f"You are authenticated with the following scopes: {scopes}")
Expand Down
6 changes: 4 additions & 2 deletions docs/examples/use_sqlite_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ async def main():
return 1
if len(sys.argv) != 2:
sys.stderr.write(
"KEY must be provided.\n\nUsage: python3 use_sqlite_token_manager.py TOKEN_KEY\n"
"KEY must be provided.\n\nUsage: python3 use_sqlite_token_manager.py"
" TOKEN_KEY\n"
)
return 1

Expand All @@ -62,7 +63,8 @@ async def main():
print(f"{await reddit.user.me()} is authenticated with all scopes")
elif "identity" in scopes:
print(
f"{await reddit.user.me()} is authenticated with the following scopes: {scopes}"
f"{await reddit.user.me()} is authenticated with the following scopes:"
f" {scopes}"
)
else:
print(f"You are authenticated with the following scopes: {scopes}")
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/models/reddit/test_emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ async def test__fetch__invalid_emoji(self, _):
subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit)
with pytest.raises(ClientException) as excinfo:
await subreddit.emoji.get_emoji("invalid")
assert str(excinfo.value) == (
f"r/{subreddit} does not have the emoji invalid"
assert (
str(excinfo.value) == f"r/{subreddit} does not have the emoji invalid"
)
with pytest.raises(ClientException) as excinfo2:
await subreddit.emoji.get_emoji("Test_png")
assert str(excinfo2.value) == (
f"r/{subreddit} does not have the emoji Test_png"
assert (
str(excinfo2.value) == f"r/{subreddit} does not have the emoji Test_png"
)

async def test_delete(self):
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/models/reddit/test_removal_reasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ async def test__fetch__invalid_reason(self, _):
with self.use_cassette():
with pytest.raises(ClientException) as excinfo:
await subreddit.mod.removal_reasons.get_reason("invalid")
assert str(excinfo.value) == (
f"Subreddit {subreddit} does not have the removal reason invalid"
assert (
str(excinfo.value)
== f"Subreddit {subreddit} does not have the removal reason invalid"
)

@mock.patch("asyncio.sleep", return_value=None)
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/models/reddit/test_subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,12 @@ async def test_submit__selftext_inline_media(self, _):
await submission.load()
assert submission.author == pytest.placeholders.username
assert (
submission.selftext
== "Text with a gif\n\n[optional caption](https://i.redd.it/s1i7ejqkgdc61.gif)\n\nan image\n\n[optional caption](https://preview.redd.it/95pza2skgdc61.png?width=128&format=png&auto=webp&s=c81d303645d9792afcdb9c47f0a6039708714274)\n\nand a video\n\n[optional caption](https://reddit.com/link/l0vyxc/video/qeg2azskgdc61/player)\n\ninline"
submission.selftext == "Text with a gif\n\n[optional"
" caption](https://i.redd.it/s1i7ejqkgdc61.gif)\n\nan"
" image\n\n[optional"
" caption](https://preview.redd.it/95pza2skgdc61.png?width=128&format=png&auto=webp&s=c81d303645d9792afcdb9c47f0a6039708714274)\n\nand"
" a video\n\n[optional"
" caption](https://reddit.com/link/l0vyxc/video/qeg2azskgdc61/player)\n\ninline"
)
assert submission.title == "title"

Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ async def test_bad_request_without_json_text_html_response(self):
)
assert (
str(excinfo.value)
== "<html><body><h1>400 Bad request</h1>\nYour browser sent an invalid request.\n</body></html>\n"
== "<html><body><h1>400 Bad request</h1>\nYour browser sent an invalid"
" request.\n</body></html>\n"
)

async def test_bare_badrequest(self):
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/models/reddit/test_subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ async def test_submit_gallery__invalid_path(self):
async def test_submit_gallery__too_long_caption(self):
message = "Caption must be 180 characters or less."
subreddit = Subreddit(self.reddit, display_name="name")
caption = "wayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy too long caption"
caption = (
"wayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
" too long caption"
)
with pytest.raises(TypeError) as excinfo:
await subreddit.submit_gallery(
"Cool title", images=[{"image_path": __file__, "caption": caption}]
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/models/reddit/test_wikipage.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def test_hash(self):

def test_repr(self):
page = WikiPage(self.reddit, subreddit=Subreddit(self.reddit, "a"), name="x")
assert repr(page) == (
"WikiPage(subreddit=Subreddit(display_name='a'), name='x')"
)
assert repr(page) == "WikiPage(subreddit=Subreddit(display_name='a'), name='x')"

def test_str(self):
page = WikiPage(self.reddit, subreddit=Subreddit(self.reddit, "a"), name="x")
Expand Down
21 changes: 16 additions & 5 deletions tests/unit/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ async def test_subreddit_rules_call(self):
await subreddit.rules()
assert (
excinfo.value.args[0]
== "Calling SubredditRules to get a list of rules is deprecated. Remove the parentheses to use the iterator. View the Async PRAW documentation on how to change the code in order to use the iterator (https://asyncpraw.readthedocs.io/en/latest/code_overview/other/subredditrules.html#asyncpraw.models.reddit.rules.SubredditRules.__call__)."
== "Calling SubredditRules to get a list of rules is deprecated. Remove the"
" parentheses to use the iterator. View the Async PRAW documentation on how"
" to change the code in order to use the iterator"
" (https://asyncpraw.readthedocs.io/en/latest/code_overview/other/subredditrules.html#asyncpraw.models.reddit.rules.SubredditRules.__call__)."
)

async def test_synchronous_context_manager(self):
Expand All @@ -87,7 +90,9 @@ async def test_synchronous_context_manager(self):
pass
assert (
excinfo.value.args[0]
== "Using this class as a synchronous context manager is deprecated and will be removed in the next release. Use this class as an asynchronous context manager instead."
== "Using this class as a synchronous context manager is deprecated and"
" will be removed in the next release. Use this class as an"
" asynchronous context manager instead."
)

def test_user_subreddit_as_dict(self):
Expand All @@ -97,12 +102,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 deprecated."
== "`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):
Expand All @@ -120,5 +129,7 @@ def test_web_socket_exception_attribute(self):
_ = exc.original_exception
assert (
excinfo.value.args[0]
== "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."
== "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."
)
13 changes: 9 additions & 4 deletions tests/unit/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def test_repr(self):
error = RedditErrorItem("BAD_SOMETHING", "invalid something", "some_field")
assert (
repr(error)
== "RedditErrorItem(error_type='BAD_SOMETHING', message='invalid something', field='some_field')"
== "RedditErrorItem(error_type='BAD_SOMETHING', message='invalid"
" something', field='some_field')"
)


Expand Down Expand Up @@ -100,7 +101,8 @@ def test_inheritance(self):
def test_message(self):
assert (
str(DuplicateReplaceException())
== "A duplicate comment has been detected. Are you attempting to call ``replace_more_comments`` more than once?"
== "A duplicate comment has been detected. Are you attempting to call"
" ``replace_more_comments`` more than once?"
)


Expand All @@ -111,7 +113,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."
)


Expand Down Expand Up @@ -184,5 +187,7 @@ def test_inheritance(self):
def test_message(self):
assert (
str(MediaPostFailed())
== "The attempted media upload action has failed. Possible causes include the corruption of media files. Check that the media file can be opened on your local machine."
== "The attempted media upload action has failed. Possible causes include"
" the corruption of media files. Check that the media file can be opened"
" on your local machine."
)
9 changes: 6 additions & 3 deletions tests/unit/test_reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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):
Expand All @@ -90,13 +91,15 @@ def test_invalid_config(self):
Reddit(timeout="test", **self.REQUIRED_DUMMY_SETTINGS)
assert (
excinfo.value.args[0]
== "An incorrect config type was given for option timeout. The expected type is int, but the given value is test."
== "An incorrect config type was given for option timeout. The expected"
" type is int, but the given value is test."
)
with pytest.raises(ValueError) as excinfo:
Reddit(ratelimit_seconds="test", **self.REQUIRED_DUMMY_SETTINGS)
assert (
excinfo.value.args[0]
== "An incorrect config type was given for option ratelimit_seconds. The expected type is int, but the given value is test."
== "An incorrect config type was given for option ratelimit_seconds. The"
" expected type is int, but the given value is test."
)

def test_info__not_list(self):
Expand Down

0 comments on commit 35fb14b

Please sign in to comment.