diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3dfed65..bf47811 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_stages: [commit, manual] repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.6 + rev: v0.3.2 hooks: - id: ruff args: [ @@ -17,7 +17,7 @@ repos: - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.7.1 + rev: v1.9.0 hooks: - id: mypy additional_dependencies: [types-requests] @@ -35,7 +35,7 @@ repos: ] - repo: https://github.com/dosisod/refurb - rev: v1.24.0 + rev: v2.0.0 hooks: - id: refurb args: [--python-version, "3.12"] diff --git a/market_arbitrage.py b/market_arbitrage.py index 729ab41..985f6e4 100644 --- a/market_arbitrage.py +++ b/market_arbitrage.py @@ -34,10 +34,7 @@ def apply_workflow( retrieve_market_orders_online = True print( - "Overwriting two arguments:\n\ti) retrieve listings: {},\n\tii) retrieve market orders: {}.".format( - retrieve_listings_from_scratch, - retrieve_market_orders_online, - ), + f"Overwriting two arguments:\n\ti) retrieve listings: {retrieve_listings_from_scratch},\n\tii) retrieve market orders: {retrieve_market_orders_online}.", ) filtered_badge_data = get_filtered_badge_data( diff --git a/src/creation_time_utils.py b/src/creation_time_utils.py index 26f4cb4..ce663e4 100644 --- a/src/creation_time_utils.py +++ b/src/creation_time_utils.py @@ -40,11 +40,7 @@ def fill_in_badges_with_next_creation_times_loaded_from_disk( app_name = aggregated_badge_data[app_id]["name"] if previously_loaded_next_creation_time is None: print( - "Loading the next creation time ({}) for {} (appID = {}) from disk.".format( - next_creation_time, - app_name, - app_id, - ), + f"Loading the next creation time ({next_creation_time}) for {app_name} (appID = {app_id}) from disk.", ) else: # NB: Data stored in data/next_creation_times.json is assumed to be more up-to-date compared to @@ -53,12 +49,7 @@ def fill_in_badges_with_next_creation_times_loaded_from_disk( # and you should delete it. Therefore, if the .json file is present on your disk, it can be # assumed that it was created by running this program, thus is more recent than the .txt file. print( - "Replacing the next creation time ({}) for {} (appID = {}) with {}, loaded from disk.".format( - previously_loaded_next_creation_time, - app_name, - app_id, - next_creation_time, - ), + f"Replacing the next creation time ({previously_loaded_next_creation_time}) for {app_name} (appID = {app_id}) with {next_creation_time}, loaded from disk.", ) return aggregated_badge_data diff --git a/src/download_steam_card_exchange.py b/src/download_steam_card_exchange.py index 349b0ff..a05c6d3 100644 --- a/src/download_steam_card_exchange.py +++ b/src/download_steam_card_exchange.py @@ -129,10 +129,10 @@ def parse_data_from_steam_card_exchange( dico[app_id]["app_id"] = app_id dico[app_id]["name"] = app_name dico[app_id]["num_cards_per_set"] = num_cards_per_set - dico[app_id][ - "gem_amount" - ] = compute_gem_amount_required_to_craft_booster_pack( - num_cards_per_set, + dico[app_id]["gem_amount"] = ( + compute_gem_amount_required_to_craft_booster_pack( + num_cards_per_set, + ) ) print(f"{len(dico)} games found in the database.") diff --git a/src/list_possible_lures.py b/src/list_possible_lures.py index 8bdea6e..d366330 100644 --- a/src/list_possible_lures.py +++ b/src/list_possible_lures.py @@ -108,13 +108,7 @@ def filter_app_ids_with_potential_profit( negative = sorted(set(app_ids).difference(filtered_app_ids), key=int) print( - "\nPositive ({}): {}\n\nNegative ({}): {}\n\nTotal ({})".format( - len(positive), - positive, - len(negative), - negative, - len(app_ids), - ), + f"\nPositive ({len(positive)}): {positive}\n\nNegative ({len(negative)}): {negative}\n\nTotal ({len(app_ids)})", ) return filtered_app_ids diff --git a/src/market_arbitrage_utils.py b/src/market_arbitrage_utils.py index 60ede45..566ea68 100644 --- a/src/market_arbitrage_utils.py +++ b/src/market_arbitrage_utils.py @@ -44,10 +44,7 @@ def filter_out_badges_never_crafted( if verbose: print( - "There are {} booster packs which are tracked, as they were crafted at least once. ({} omitted)".format( - len(filtered_badge_data), - len(aggregated_badge_data) - len(filtered_badge_data), - ), + f"There are {len(filtered_badge_data)} booster packs which are tracked, as they were crafted at least once. ({len(aggregated_badge_data) - len(filtered_badge_data)} omitted)", ) return filtered_badge_data @@ -77,10 +74,7 @@ def filter_out_badges_recently_crafted( if verbose: print( - "There are {} booster packs which can be immediately crafted. ({} excluded because of cooldown)".format( - len(filtered_badge_data), - len(aggregated_badge_data) - len(filtered_badge_data), - ), + f"There are {len(filtered_badge_data)} booster packs which can be immediately crafted. ({len(aggregated_badge_data) - len(filtered_badge_data)} excluded because of cooldown)", ) return filtered_badge_data @@ -169,13 +163,7 @@ def filter_out_badges_with_low_sell_price( if verbose: print( - "There are {} {} with sell price unknown ({}) or strictly higher than {} ({}).".format( - len(filtered_badge_data), - category_name, - unknown_price_counter, - threshold_name, - len(filtered_badge_data) - unknown_price_counter, - ), + f"There are {len(filtered_badge_data)} {category_name} with sell price unknown ({unknown_price_counter}) or strictly higher than {threshold_name} ({len(filtered_badge_data) - unknown_price_counter}).", ) return filtered_badge_data @@ -209,9 +197,7 @@ def find_badge_arbitrages( if verbose: print( - "Bid not found for {}. Reason is likely that you asked not to retrieve market orders.".format( - listing_hash, - ), + f"Bid not found for {listing_hash}. Reason is likely that you asked not to retrieve market orders.", ) bid_without_fee = compute_sell_price_without_fee(bid_including_fee) @@ -244,9 +230,9 @@ def find_badge_arbitrages( ] except KeyError: badge_arbitrages[listing_hash]["gem_amount"] = None - badge_arbitrages[listing_hash][ - "gem_price_including_fee" - ] = individual_badge_data["gem_price"] + badge_arbitrages[listing_hash]["gem_price_including_fee"] = ( + individual_badge_data["gem_price"] + ) badge_arbitrages[listing_hash]["sell_price"] = individual_badge_data[ "sell_price" ] @@ -305,14 +291,7 @@ def print_arbitrages( replace_spaces=True, ) - listing_hash_formatted_for_markdown = ( - "[[store]({})][[market]({})] [{}]({})".format( - get_steam_store_url(app_id), - markdown_compatible_steam_market_url, - listing_hash, - get_steamcardexchange_url(app_id), - ) - ) + listing_hash_formatted_for_markdown = f"[[store]({get_steam_store_url(app_id)})][[market]({markdown_compatible_steam_market_url})] [{listing_hash}]({get_steamcardexchange_url(app_id)})" else: listing_hash_formatted_for_markdown = listing_hash diff --git a/src/market_buzz_utils.py b/src/market_buzz_utils.py index 2e6c945..6f6423c 100644 --- a/src/market_buzz_utils.py +++ b/src/market_buzz_utils.py @@ -145,27 +145,12 @@ def print_packs_with_high_buzz( num_different_items_of_uncommon_rarity = item_rarity_pattern["uncommon"] num_different_items_of_rare_rarity = item_rarity_pattern["rare"] - item_rarity_pattern_info = ( - " ; rarity pattern C/UC/R: {}/{}/{} items".format( - num_different_items_of_common_rarity, - num_different_items_of_uncommon_rarity, - num_different_items_of_rare_rarity, - ) - ) + item_rarity_pattern_info = f" ; rarity pattern C/UC/R: {num_different_items_of_common_rarity}/{num_different_items_of_uncommon_rarity}/{num_different_items_of_rare_rarity} items" except (TypeError, KeyError): item_rarity_pattern_info = "" print( - "{:3}) [[store]({})][[market]({})] [{}]({}) ; bid: {}€ (volume: {}){}".format( - i + 1, - get_steam_store_url(app_id), - markdown_compatible_steam_market_url, - app_name, - get_steamcardexchange_url(app_id), - bid, - bid_volume, - item_rarity_pattern_info, - ), + f"{i + 1:3}) [[store]({get_steam_store_url(app_id)})][[market]({markdown_compatible_steam_market_url})] [{app_name}]({get_steamcardexchange_url(app_id)}) ; bid: {bid}€ (volume: {bid_volume}){item_rarity_pattern_info}", ) @@ -212,9 +197,9 @@ def fill_in_badge_data_with_data_from_steam_card_exchange( "gem_amount" ] - aggregated_badge_data[app_id][ - "gem_amount" - ] = gem_amount_required_to_craft_booster_pack + aggregated_badge_data[app_id]["gem_amount"] = ( + gem_amount_required_to_craft_booster_pack + ) aggregated_badge_data[app_id]["gem_price"] = ( gem_amount_required_to_craft_booster_pack * gem_price ) diff --git a/src/market_foil_utils.py b/src/market_foil_utils.py index e47d78a..8b09096 100644 --- a/src/market_foil_utils.py +++ b/src/market_foil_utils.py @@ -551,10 +551,7 @@ def find_listing_hashes_with_unknown_goo_value( if verbose: print( - "Unknown goo values for:\n{}\nTotal: {} appIDs with unknown goo value.".format( - app_ids_with_unknown_goo_value, - len(app_ids_with_unknown_goo_value), - ), + f"Unknown goo values for:\n{app_ids_with_unknown_goo_value}\nTotal: {len(app_ids_with_unknown_goo_value)} appIDs with unknown goo value.", ) return app_ids_with_unknown_goo_value @@ -725,10 +722,7 @@ def find_app_ids_with_unknown_item_type_for_their_representatives( if verbose: print( - "Unknown item types for:\n{}\nTotal: {} appIDs with unknown item type for their representative listing hashes.".format( - app_ids_with_unreliable_goo_details, - len(app_ids_with_unreliable_goo_details), - ), + f"Unknown item types for:\n{app_ids_with_unreliable_goo_details}\nTotal: {len(app_ids_with_unreliable_goo_details)} appIDs with unknown item type for their representative listing hashes.", ) return app_ids_with_unreliable_goo_details diff --git a/src/market_order.py b/src/market_order.py index 2977051..683f863 100644 --- a/src/market_order.py +++ b/src/market_order.py @@ -187,14 +187,7 @@ def download_market_order_data( if verbose: print( - "Listing: {} ; item id: {} ; ask: {:.2f}€ ({}) ; bid: {:.2f}€ ({})".format( - listing_hash, - item_nameid, - ask_price, - ask_volume, - bid_price, - bid_volume, - ), + f"Listing: {listing_hash} ; item id: {item_nameid} ; ask: {ask_price:.2f}€ ({ask_volume}) ; bid: {bid_price:.2f}€ ({bid_volume})", ) return bid_price, ask_price, bid_volume, ask_volume diff --git a/src/market_utils.py b/src/market_utils.py index 299edb2..412bd7d 100644 --- a/src/market_utils.py +++ b/src/market_utils.py @@ -39,10 +39,7 @@ def filter_out_dubious_listing_hashes( if verbose: print( - "There are {} seemingly valid market listings. ({} omitted because of a dubious listing hash)".format( - len(filtered_listings), - len(all_listings) - len(filtered_listings), - ), + f"There are {len(filtered_listings)} seemingly valid market listings. ({len(all_listings) - len(filtered_listings)} omitted because of a dubious listing hash)", ) return filtered_listings @@ -161,9 +158,9 @@ def aggregate_badge_data( aggregated_badge_data[app_id] = {} aggregated_badge_data[app_id]["name"] = app_name aggregated_badge_data[app_id]["listing_hash"] = listing_hash - aggregated_badge_data[app_id][ - "gem_amount" - ] = gem_amount_required_to_craft_booster_pack + aggregated_badge_data[app_id]["gem_amount"] = ( + gem_amount_required_to_craft_booster_pack + ) aggregated_badge_data[app_id]["gem_price"] = ( gem_amount_required_to_craft_booster_pack * gem_price ) diff --git a/src/sack_of_gems.py b/src/sack_of_gems.py index 3d7dc9e..8c356b1 100644 --- a/src/sack_of_gems.py +++ b/src/sack_of_gems.py @@ -98,19 +98,13 @@ def get_gem_price( else: sack_of_gems_price = enforced_sack_of_gems_price print( - "[manual input] A sack of {} gems can allegedly be bought for {:.2f} €.".format( - get_num_gems_per_sack_of_gems(), - sack_of_gems_price, - ), + f"[manual input] A sack of {get_num_gems_per_sack_of_gems()} gems can allegedly be bought for {sack_of_gems_price:.2f} €.", ) if minimum_allowed_sack_of_gems_price is not None: sack_of_gems_price = max(minimum_allowed_sack_of_gems_price, sack_of_gems_price) print( - "[manual adjustment] The price of a sack of gems is set to {:.2f} € (minimum allowed: {:.2f} €).".format( - sack_of_gems_price, - minimum_allowed_sack_of_gems_price, - ), + f"[manual adjustment] The price of a sack of gems is set to {sack_of_gems_price:.2f} € (minimum allowed: {minimum_allowed_sack_of_gems_price:.2f} €).", ) num_gems_per_sack_of_gems = get_num_gems_per_sack_of_gems()