-
Notifications
You must be signed in to change notification settings - Fork 3
Sourcery Starbot ⭐ refactored prcutler/nflpool #514
base: master
Are you sure you want to change the base?
Conversation
data = dict() | ||
data = {} |
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 BaseController.data_dict
refactored with the following changes:
- Replace dict() with {} (
dict-literal
)
user_id = cookie_auth.get_user_id_via_auth_cookie(self.request) | ||
return user_id | ||
return cookie_auth.get_user_id_via_auth_cookie(self.request) |
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 BaseController.logged_in_user_id
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if week >= 17: | ||
week = "Final" | ||
else: | ||
week = "Week " + str(week_query[0]) | ||
|
||
week = "Final" if week >= 17 else "Week " + str(week_query[0]) |
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 StandingsController.season
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
|
||
import hashlib | ||
import os | ||
import nflpool | ||
|
||
__full_path = os.path.dirname(os.path.abspath(nflpool.__file__)) | ||
__hash_lookup = dict() | ||
__hash_lookup = {} |
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 22-22
refactored with the following changes:
- Replace dict() with {} (
dict-literal
)
account = session.query(Account).filter(Account.email == email).first() | ||
|
||
return account | ||
return session.query(Account).filter(Account.email == email).first() |
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 AccountService.find_account_by_email
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
tz = pendulum.timezone("America/New_York") | ||
|
||
return tz | ||
return pendulum.timezone("America/New_York") |
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 GameDayService.timezone
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
time_due = season_start_date.format("h:m A") | ||
# print("Season start date", season_start_date, "time_due", time_due) | ||
|
||
return time_due | ||
return season_start_date.format("h:m A") |
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 GameDayService.time_due
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
picks_due_date = season_start_date.to_formatted_date_string() | ||
# print("picks_due_date", picks_due_date) | ||
|
||
return picks_due_date | ||
return season_start_date.to_formatted_date_string() |
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 GameDayService.picks_due
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
days = delta.days | ||
|
||
return days | ||
return delta.days |
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 GameDayService.delta_days
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
hours = delta.hours | ||
|
||
return hours | ||
return delta.hours |
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 GameDayService.delta_hours
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
minutes = delta.minutes | ||
|
||
return minutes | ||
return delta.minutes |
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 GameDayService.delta_minutes
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
|
||
x = 0 |
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 NewInstallService.get_team_info
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Replace manual loop counter with call to enumerate (
convert-to-enumerate
)
if x == 1: | ||
if division_id == 1: | ||
division = "East" | ||
elif x == 2: | ||
elif division_id == 2: | ||
division = "North" | ||
elif x == 3: | ||
elif division_id == 3: |
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 NewInstallService.create_division_info
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
) - Use previously assigned local variable (
use-assigned-variable
)
if x == 1: | ||
if pick_type_id == 1: | ||
for y in range(1, 5): | ||
place = y | ||
|
||
if y == 1: | ||
if place == 1: | ||
points = 50 | ||
elif y == 2: | ||
elif place == 2: | ||
points = 30 | ||
elif y == 4: | ||
elif place == 4: |
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 NewInstallService.create_pick_type_points
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
) - Use previously assigned local variable (
use-assigned-variable
)
session.commit() | ||
|
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 NewSeasonService.create_season
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
account_info = session.query(Account).filter(Account.id == user_id).all() | ||
|
||
return account_info | ||
return session.query(Account).filter(Account.id == user_id).all() |
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 ViewPicksService.get_account_info
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
seasons_played = ( | ||
return ( | ||
session.query(PlayerPicks.season) | ||
.distinct(PlayerPicks.season) | ||
.filter(Account.id == user_id) | ||
) | ||
|
||
return seasons_played |
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 ViewPicksService.seasons_played
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
picks_query = ( | ||
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 ViewPicksService.display_picks
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
picks_query = ( | ||
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 ViewPicksService.change_picks
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
current_season = season_row.current_season | ||
|
||
return current_season | ||
return season_row.current_season |
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_seasons
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
x = 0 | ||
|
||
# print(type(standings_data), standings_data) | ||
|
||
for teams in standings_data: | ||
for x, teams in enumerate(standings_data): |
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 WeeklyStatsService.get_rankings
refactored with the following changes:
- Replace manual loop counter with call to enumerate (
convert-to-enumerate
)
x = 0 | ||
|
||
for teams in points_for_data: | ||
for x, teams in enumerate(points_for_data): | ||
team_id = int(points_for_data[x]["team"]["id"]) | ||
points_for = points_for_data[x]["stats"]["standings"]["pointsFor"] | ||
|
||
week = TimeService.get_week() | ||
|
||
x += 1 |
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 WeeklyStatsService.get_points_for
refactored with the following changes:
- Replace manual loop counter with call to enumerate (
convert-to-enumerate
)
x = 0 | ||
|
||
tiebreaker_json = response.json() | ||
tiebreaker_data = tiebreaker_json["teamStatsTotals"] | ||
|
||
for teams in tiebreaker_data: | ||
for x, teams in enumerate(tiebreaker_data): |
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 WeeklyStatsService.get_tiebreaker
refactored with the following changes:
- Replace manual loop counter with call to enumerate (
convert-to-enumerate
)
if not any(char in symbol for char in self.password): | ||
if all(char not in symbol for char in self.password): |
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 RegisterViewModel.validate
refactored with the following changes:
- Invert any/all to simplify comparisons (
invert-any-all
)
if self.reset.was_used: | ||
self.error_msg = "This reset code has already been used." | ||
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 ResetPasswordViewModel.validate
refactored with the following changes:
- Merge repeated if statements into single if (
merge-repeated-ifs
) - Remove unreachable code (
remove-unreachable-code
)
player_list = [ | ||
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 activeplayer_json
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: