-
-
Notifications
You must be signed in to change notification settings - Fork 14
Conversation
I'll work through this and take a look; the mixed |
tor/core/admin_commands.py
Outdated
:param reply: Object, the message object that contains the requested | ||
command | ||
:param config: the global config object | ||
:param reply: Object, The message object that contains the requested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather this be :param reply: The message object ...
:param reply: Object; the message...
@@ -44,38 +44,38 @@ def process_command(reply, config): | |||
except KeyError: | |||
if from_moderator(reply, config): | |||
reply.reply( | |||
"That command hasn't been implemented yet ):" | |||
"\n\nMessage a dev to make your dream come true." | |||
'That command hasn\'t been implemented yet ):' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous \
are the other reason that some of these have double quotes and some of them don't.
tor/core/admin_commands.py
Outdated
if not from_moderator(reply, config): | ||
reply.reply(_(random.choice(config.no_gifs))) | ||
logging.info( | ||
f'{reply.author.name} just tried to override. Lolno.' | ||
f'{reply.author.name} just tried to override. Lol no.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular character combination was deliberate. 😄
tor/core/inbox.py
Outdated
# Wrap each phrase in double-quotes (") and commas in between | ||
phrases = '"' + '", "'.join(phrases) + '"' | ||
# Wrap each phrase in double-quotes (") and commas in between. | ||
phrases = f'"{", ".join(phrases)}"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not do the same thing.
>>> phrases = ['asdf', 'qwer', 'erty']
>>> '"' + '", "'.join(phrases) + '"'
'"asdf", "qwer", "erty"'
>>> f'"{", ".join(phrases)}"'
'"asdf, qwer, erty"'
>>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, it might work better to iterate in a different way:
phrases = ', '.join([f'"{phrase}"' for phrase in phrases])
This way we have wrapping of each phrase in the list in double-quotes, then join it by commas. Two separate actions.
tor/core/user_interaction.py
Outdated
@@ -38,8 +38,8 @@ def coc_accepted(post, config): | |||
""" | |||
Verifies that the user is in the Redis set "accepted_CoC". | |||
|
|||
:param post: the Comment object containing the claim. | |||
:param config: the global config dict. | |||
:param post: The comment object containing the claim. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment
here refers to the Comment
class of PRAW.
tor/core/user_interaction.py
Outdated
@@ -76,14 +76,14 @@ def process_coc(post, config): | |||
':fb-like:' | |||
]) | |||
|
|||
# Have they already been added? If 0, then just act like they said `claim` | |||
# Have they already been added? If no, then just act like they said `claim` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0
is the literal return value.
tor/core/user_interaction.py
Outdated
@@ -95,8 +95,8 @@ def process_claim(post, config): | |||
Handles comment replies containing the word 'claim' and routes | |||
based on a basic decision tree. | |||
|
|||
:param post: The Comment object containing the claim. | |||
:param config: the global config dict. | |||
:param post: The comment object containing the claim. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
References the Comment
class from PRAW.
# today | ||
if top_parent.link_flair_text in ['', None]: | ||
if top_parent.link_flair_text in ('', None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to SO, if this is done 10,000,000 times, switching to tuples will save us a grand total of... 0.005 seconds. My personal opinion is that it decreases clarity as well. I'm really not sure it's worth it; @TheLonelyGhost what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't really mean for it to be a primarily speed based change, but stylistic. Regardless of the direction this ends up going, the usage of each should be made more consistent; while there are three x in [...]
there is one instance of x in (...)
:
Line 192 in 3b8e9a0
elif item.subject in ('comment reply', 'post reply'): |
I prefer this style, and so switched the rest to look like this.
I've reviewed the particular pieces that I've found while reading through. There is one specific change in functionality that will need to be reverted, but the rest are stylistic. I'm not sure that I agree with a lot of the code comment changes simply because I perceive that a comment's job is to blend into the background and only be looked at if needed, which is why I don't capitalize a lot of them unless I want them to be seen. This is probably weird, but it's just the way I've been doing it over the years. The changes from single quotes to double quotes are unnecessary as written above; there's no real need for that change to happen. If anything, we should be focusing on slowly redoing the rest of the codebase. As it stands, applying All that being said, there are some changes in here that I like - I'm not sure about the majority of them but the ones that increase clarity I'm all for. |
tor/core/users.py
Outdated
@@ -39,9 +39,9 @@ def __init__( | |||
Create our own Redis connection if one is not passed in. | |||
We also assume that there is already a logging object created. | |||
|
|||
:param username: String; the username we're looking for. No fuzzing | |||
:param username: String; The username we're looking for. No fuzzing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no letters after a semicolon should be capitalized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github says I need to leave a comment when I request changes, so please see above comments. 😄
After discussion with the core team, we've elected that these changes here don't quite match our preferences and style that we've decided to take with the codebase. We're also in the process of working out a lot of these kinks using Black, which will shift the bulk of formatting away from manual labor and also would overwrite a lot of these changes anyway. Thanks for submitting, but we won't be merging this one. |
I noticed some small grammar errors and code style problems. This fixes lots of small things, but the most common ones are:
Double quotes are turned into single quotes, because most of the codebase used them, but not all.
Every sentences' beginning is capitalized and end with a period, along with other small grammar fixes/word choices.
x in ['foo', 'bar']
is turned intoy in ('foo', 'bar')
, because tuples are immutable and don't have the(tiny) overhead lists do... basically just boils down to consistency and style.This shouldn't change any actual functions of the script. If it does, it's a mistake.