-
Notifications
You must be signed in to change notification settings - Fork 8
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
Sourcery Starbot ⭐ refactored schorrm/pybaseball #19
base: master
Are you sure you want to change the base?
Conversation
res = requests.get(url, timeout=None).content | ||
draft_results = pd.read_html(res) | ||
return draft_results | ||
res = requests.get(url, timeout=None).content | ||
return pd.read_html(res) |
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_draft_results
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
table = get_table(soup, ind) | ||
return table | ||
return get_table(soup, ind) |
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 batting_stats
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
# do this for every table in the lahman db so they can exist as separate functions | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Parks.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
# do this for every table in the lahman db so they can exist as separate functions | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Parks.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 parks
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "AllstarFull.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "AllstarFull.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 all_star_full
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Appearances.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Appearances.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 appearances
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "FieldingPost.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "FieldingPost.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 fielding_post
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "HallOfFame.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "HallOfFame.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 hall_of_fame
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "HomeGames.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "HomeGames.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 home_games
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Managers.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Managers.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 managers
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "ManagersHalf.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "ManagersHalf.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 managers_half
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "People.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "People.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 people
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Pitching.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Pitching.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 pitching
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "PitchingPost.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "PitchingPost.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 pitching_post
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Salaries.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "Salaries.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 salaries
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
z = get_lahman_zip() | ||
f = os.path.join(base_string, "SeriesPost.csv") | ||
data = pd.read_csv(f if z is None else z.open(f), header=0, sep=',', quotechar="'") | ||
return data | ||
z = get_lahman_zip() | ||
f = os.path.join(base_string, "SeriesPost.csv") | ||
return pd.read_csv( | ||
f if z is None else z.open(f), header=0, sep=',', quotechar="'" | ||
) |
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 series_post
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if(season>=1969): | ||
if (season>=1969): |
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_tables
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
elif season<=1904: code = BeautifulSoup(t[15], "lxml") | ||
else: | ||
code = BeautifulSoup(t[15], "lxml") |
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 standings
refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if
)
# 3 days or less -> a quick one-shot request. Greater than 3 days -> break it into multiple smaller queries | ||
small_query_threshold = 5 |
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 statcast
refactored with the following changes:
- Move assignments closer to their usage (
move-assign
)
df = split_request(start_dt, end_dt, player_id, url) | ||
return df | ||
return split_request(start_dt, end_dt, player_id, url) |
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 statcast_batter
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
data = pd.read_csv(io.StringIO(res.decode('utf-8'))) | ||
return data | ||
return pd.read_csv(io.StringIO(res.decode('utf-8'))) |
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 statcast_batter_exitvelo_barrels
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
df = split_request(start_dt, end_dt, player_id, url) | ||
return df | ||
return split_request(start_dt, end_dt, player_id, url) |
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 statcast_pitcher
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
else: | ||
pass | ||
|
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 postprocessing
refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass
)
data = pd.read_html(str(table))[0] | ||
return data | ||
return pd.read_html(str(table))[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 get_table
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
teamUrl = "" if teamName == None else teamName.lower() + '/' | ||
teamUrl = "" if teamName is None else teamName.lower() + '/' | ||
url = f"https://www.mlb.com/{teamUrl}prospects/stats/top-prospects" | ||
res = requests.get(url, timeout=None).content | ||
prospectList = pd.read_html(res) | ||
if playerType == "batters": | ||
topBattingProspects = postprocess(prospectList[0]) | ||
return topBattingProspects | ||
return postprocess(prospectList[0]) | ||
elif playerType == "pitchers": | ||
topPitchingProspects = postprocess(prospectList[1]) | ||
return topPitchingProspects | ||
elif playerType == None: | ||
return postprocess(prospectList[1]) | ||
elif playerType is 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.
Function top_prospects
refactored with the following changes:
- Use x is None rather than x == None (
none-compare
) - 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: