Skip to content
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

Weird output of dictionary of dictionaries (it does not happen on master) #846

Closed
woctezuma opened this issue May 9, 2019 · 1 comment
Closed

Comments

@woctezuma
Copy link

woctezuma commented May 9, 2019

Operating system: Windows 10
Python version: 3.7
Black version: 19.3b0 (installed with pip)
Does also happen on master: No.

I try to format this code:

def find_badge_arbitrages(badge_data, market_order_dict):
    badge_arbitrages = dict()

    for app_id in badge_data.keys():
        individual_badge_data = badge_data[app_id]

        listing_hash = individual_badge_data['listing_hash']

        badge_arbitrages[listing_hash] = dict()

        badge_arbitrages[listing_hash]['name'] = individual_badge_data['name']
        badge_arbitrages[listing_hash]['gem_amount'] = individual_badge_data['gem_amount']
        badge_arbitrages[listing_hash]['gem_price_including_fee'] = individual_badge_data['gem_price']

        badge_arbitrages[listing_hash]['ask_including_fee'] = market_order_dict[listing_hash]['ask']
        badge_arbitrages[listing_hash]['ask_volume'] = market_order_dict[listing_hash]['ask_volume']

    return badge_arbitrages

With the version of black installed with pip, I get a weirdly inconsistent output:

def find_badge_arbitrages(badge_data, market_order_dict):
    badge_arbitrages = dict()

    for app_id in badge_data.keys():
        individual_badge_data = badge_data[app_id]

        listing_hash = individual_badge_data["listing_hash"]

        badge_arbitrages[listing_hash] = dict()

        badge_arbitrages[listing_hash]["name"] = individual_badge_data["name"]
        badge_arbitrages[listing_hash]["gem_amount"] = individual_badge_data[
            "gem_amount"
        ]
        badge_arbitrages[listing_hash][
            "gem_price_including_fee"
        ] = individual_badge_data["gem_price"]

        badge_arbitrages[listing_hash]["ask_including_fee"] = market_order_dict[
            listing_hash
        ]["ask"]
        badge_arbitrages[listing_hash]["ask_volume"] = market_order_dict[listing_hash][
            "ask_volume"
        ]

    return badge_arbitrages

With the online formatter, I get a nice output:

def find_badge_arbitrages(badge_data, market_order_dict):
    badge_arbitrages = dict()

    for app_id in badge_data.keys():
        individual_badge_data = badge_data[app_id]

        listing_hash = individual_badge_data["listing_hash"]

        badge_arbitrages[listing_hash] = dict()

        badge_arbitrages[listing_hash][
            "name"
        ] = individual_badge_data["name"]
        badge_arbitrages[listing_hash][
            "gem_amount"
        ] = individual_badge_data["gem_amount"]
        badge_arbitrages[listing_hash][
            "gem_price_including_fee"
        ] = individual_badge_data["gem_price"]

        badge_arbitrages[listing_hash][
            "ask_including_fee"
        ] = market_order_dict[listing_hash]["ask"]
        badge_arbitrages[listing_hash][
            "ask_volume"
        ] = market_order_dict[listing_hash]["ask_volume"]

    return badge_arbitrages

I hope the version installed with pip will catch up with the master version.

@zsol
Copy link
Collaborator

zsol commented May 9, 2019

soon. :) #517

@zsol zsol closed this as completed May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants