fix: correct Dict[str, any] to Dict[str, Any] in type annotations (#15)
Closes #15 `any` (lowercase) refers to the builtin function, not `typing.Any`. Added `Any` to the `typing` imports in both files and updated the `cardset` parameter annotation accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f1ca14791d
commit
b39d3283fd
@ -3,7 +3,7 @@ import urllib.parse
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
from typing import Dict
|
||||
from typing import Any, Dict
|
||||
from creation_helpers import (
|
||||
get_all_pybaseball_ids,
|
||||
sanitize_name,
|
||||
@ -158,8 +158,8 @@ async def create_new_players(
|
||||
{
|
||||
"p_name": f"{f_name} {l_name}",
|
||||
"cost": NEW_PLAYER_COST,
|
||||
"image": f'{card_base_url}/{df_data["player_id"]}/battingcard'
|
||||
f'{urllib.parse.quote("?d=")}{release_dir}',
|
||||
"image": f"{card_base_url}/{df_data['player_id']}/battingcard"
|
||||
f"{urllib.parse.quote('?d=')}{release_dir}",
|
||||
"mlbclub": CLUB_LIST[df_data["Tm_vL"]],
|
||||
"franchise": FRANCHISE_LIST[df_data["Tm_vL"]],
|
||||
"cardset_id": cardset["id"],
|
||||
@ -302,7 +302,7 @@ async def calculate_batting_ratings(offense_stats: pd.DataFrame, to_post: bool):
|
||||
|
||||
|
||||
async def post_player_updates(
|
||||
cardset: Dict[str, any],
|
||||
cardset: Dict[str, Any],
|
||||
card_base_url: str,
|
||||
release_dir: str,
|
||||
player_desc: str,
|
||||
@ -432,8 +432,8 @@ async def post_player_updates(
|
||||
[
|
||||
(
|
||||
"image",
|
||||
f'{card_base_url}/{df_data["player_id"]}/battingcard'
|
||||
f'{urllib.parse.quote("?d=")}{release_dir}',
|
||||
f"{card_base_url}/{df_data['player_id']}/battingcard"
|
||||
f"{urllib.parse.quote('?d=')}{release_dir}",
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
import urllib.parse
|
||||
import pandas as pd
|
||||
from typing import Dict
|
||||
from typing import Any, Dict
|
||||
|
||||
from creation_helpers import (
|
||||
get_all_pybaseball_ids,
|
||||
@ -196,8 +196,8 @@ async def create_new_players(
|
||||
{
|
||||
"p_name": f"{f_name} {l_name}",
|
||||
"cost": NEW_PLAYER_COST,
|
||||
"image": f'{card_base_url}/{df_data["player_id"]}/'
|
||||
f'pitchingcard{urllib.parse.quote("?d=")}{release_dir}',
|
||||
"image": f"{card_base_url}/{df_data['player_id']}/"
|
||||
f"pitchingcard{urllib.parse.quote('?d=')}{release_dir}",
|
||||
"mlbclub": CLUB_LIST[df_data["Tm_vL"]],
|
||||
"franchise": FRANCHISE_LIST[df_data["Tm_vL"]],
|
||||
"cardset_id": cardset["id"],
|
||||
@ -268,7 +268,7 @@ async def calculate_pitching_cards(
|
||||
|
||||
def create_pitching_card(df_data):
|
||||
logger.info(
|
||||
f'Creating pitching card for {df_data["name_first"]} {df_data["name_last"]} / fg ID: {df_data["key_fangraphs"]}'
|
||||
f"Creating pitching card for {df_data['name_first']} {df_data['name_last']} / fg ID: {df_data['key_fangraphs']}"
|
||||
)
|
||||
pow_data = cde.pow_ratings(
|
||||
float(df_data["Inn_def"]), df_data["GS"], df_data["G"]
|
||||
@ -298,11 +298,11 @@ async def calculate_pitching_cards(
|
||||
int(df_data["GF"]), int(df_data["SV"]), int(df_data["G"])
|
||||
),
|
||||
"hand": df_data["pitch_hand"],
|
||||
"batting": f'#1W{df_data["pitch_hand"]}-C',
|
||||
"batting": f"#1W{df_data['pitch_hand']}-C",
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f'Skipping fg ID {df_data["key_fangraphs"]} due to: {e}')
|
||||
logger.error(f"Skipping fg ID {df_data['key_fangraphs']} due to: {e}")
|
||||
|
||||
print("Calculating pitching cards...")
|
||||
pitching_stats.apply(create_pitching_card, axis=1)
|
||||
@ -333,7 +333,7 @@ async def create_position(
|
||||
|
||||
def create_pit_position(df_data):
|
||||
if df_data["key_bbref"] in df_p.index:
|
||||
logger.debug(f'Running P stats for {df_data["p_name"]}')
|
||||
logger.debug(f"Running P stats for {df_data['p_name']}")
|
||||
pit_positions.append(
|
||||
{
|
||||
"player_id": int(df_data["player_id"]),
|
||||
@ -364,7 +364,7 @@ async def create_position(
|
||||
)
|
||||
except Exception:
|
||||
logger.error(
|
||||
f'Could not create pitcher position for {df_data["key_bbref"]}'
|
||||
f"Could not create pitcher position for {df_data['key_bbref']}"
|
||||
)
|
||||
|
||||
print("Calculating pitcher fielding lines now...")
|
||||
@ -386,7 +386,7 @@ async def calculate_pitcher_ratings(pitching_stats: pd.DataFrame, post_pitchers:
|
||||
pitching_ratings.extend(cpi.get_pitcher_ratings(df_data))
|
||||
except Exception:
|
||||
logger.error(
|
||||
f'Could not create a pitching card for {df_data["key_fangraphs"]}'
|
||||
f"Could not create a pitching card for {df_data['key_fangraphs']}"
|
||||
)
|
||||
|
||||
print("Calculating card ratings...")
|
||||
@ -400,7 +400,7 @@ async def calculate_pitcher_ratings(pitching_stats: pd.DataFrame, post_pitchers:
|
||||
|
||||
|
||||
async def post_player_updates(
|
||||
cardset: Dict[str, any],
|
||||
cardset: Dict[str, Any],
|
||||
player_description: str,
|
||||
card_base_url: str,
|
||||
release_dir: str,
|
||||
@ -525,8 +525,8 @@ async def post_player_updates(
|
||||
[
|
||||
(
|
||||
"image",
|
||||
f'{card_base_url}/{df_data["player_id"]}/pitchingcard'
|
||||
f'{urllib.parse.quote("?d=")}{release_dir}',
|
||||
f"{card_base_url}/{df_data['player_id']}/pitchingcard"
|
||||
f"{urllib.parse.quote('?d=')}{release_dir}",
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user