-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| if path.exists(self.pickle_path): # Ask if they intend to overwrite existing pickle | ||
| if input(f"overwrite {self.pickle_path}? (Y/N)\n").upper() != "Y": | ||
| self.pickle_path = self.pathify(self.gen_pickle_name()) | ||
| if ( | ||
| path.exists(self.pickle_path) | ||
| and input(f"overwrite {self.pickle_path}? (Y/N)\n").upper() != "Y" | ||
| ): | ||
| self.pickle_path = self.pathify(self.gen_pickle_name()) |
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.
Function NgramModel.__init__ refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs)
This removes the following comments ( why? ):
# Ask if they intend to overwrite existing pickle
| list_of_tup = [] | ||
|
|
||
| for i in range(len(words) + 1 - self.n): | ||
| list_of_tup.append((tuple(words[i + j] for j in range(self.n - 1)), words[i + self.n - 1])) | ||
|
|
||
| return list_of_tup | ||
| return [ | ||
| (tuple(words[i + j] for j in range(self.n - 1)), words[i + self.n - 1]) | ||
| for i in range(len(words) + 1 - self.n) | ||
| ] |
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.
Function NgramModel.generate_Ngrams refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
|
|
||
| def calculate_freq(self, context: tuple): | ||
| freq = sum(freq for freq in self.context_options[context].values()) | ||
| freq = sum(self.context_options[context].values()) |
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.
Function NgramModel.calculate_freq refactored with the following changes:
- Simplify generator expression (
simplify-generator)
| pin = driver.find_element(By.CSS_SELECTOR, "kbd > code").get_attribute("innerText") | ||
| return pin | ||
| return driver.find_element(By.CSS_SELECTOR, "kbd > code").get_attribute( | ||
| "innerText" | ||
| ) |
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.
Function get_pin refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| for i in signal.valid_signals(): | ||
| if (i == signal.SIGKILL or | ||
| i == signal.SIGSTOP): | ||
| if i in [signal.SIGKILL, signal.SIGSTOP]: |
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.
Lines 57-58 refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| """ | ||
| search_param["query"] = keyword | ||
| to_return = dict() | ||
| to_return = {} |
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.
Function Twitter.get_tweets refactored with the following changes:
- Replace
dict()with{}(dict-literal)
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!