TypeError: argument of type NoneType is not iterable in python

Viewed 863

I currently have a function that iterates through a dictionary of contract addresses and then adds them into the allowedTokens and then set their price feed.

I set the values of the dictionary in a function, then call another function to iterate through it:

..........

dict_of_allowed_tokens = {
        dapp_token: get_contract("dai_usd_price_feed"),
        fau_token: get_contract("dai_usd_price_feed"),
        weth_token: get_contract("eth_usd_price_feed"),
    }

    add_allowed_tokens(token_farm, dict_of_allowed_tokens, account)

    return token_farm, dapp_token

Here is the add_allowed_tokens

def add_allowed_tokens(token_farm, dict_of_allowed_tokens, account):
    for token in dict_of_allowed_tokens:
        add_tx = token_farm.addAllowedTokens(token.address, {"from": account})
        add_tx.wait(1)
        set_tx = token_farm.setPriceFeedContract(
            token.address, dict_of_allowed_tokens[token], {"from": account}
        )
        set_tx.wait(1)
    return token_farm

Maybe the problem is something in the get_contract() function when setting the dictionary values. Here is the code for the get contract: (may, may not be related to this)

contract_to_mock = {
    "link_token": LinkToken,
    "eth_usd_price_feed": MockV3Aggregator,
    "dai_usd_price_feed": MockV3Aggregator,
    "oracle": MockOracle,
    "fau_token": MockFAU,
    "weth_token": MockWETH,
}

def get_contract(contract_name):

    contract_type = contract_to_mock[contract_name]
    if network.show_active() in NON_FORKED_LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        if len(contract_type) <= 0:
            deploy_mocks()
        contract = contract_type[-1]
    else:
        try:
            contract_address = config["networks"][network.show_active()][contract_name]
            contract = Contract.from_abi(
                contract_type._name, contract_address, contract_type.abi
            )
        except KeyError:
            print(
                f"{network.show_active()} address not found, perhaps you should add it to the config or deploy mocks?"
            )
            print(
                f"brownie run scripts/deploy_mocks.py --network {network.show_active()}"
            )
    return contract

I am getting this error in my console:

Brownie v1.18.1 - Python development framework for Ethereum

  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/run.py", line 42, in main
    active_project.load_config()
  File "brownie/project/main.py", line 462, in load_config
    _load_project_config(self._path)
  File "brownie/_config.py", line 222, in _load_project_config
    and "cmd_settings" in values
TypeError: argument of type 'NoneType' is not iterable

Thanks for the help, if this is confusing or worded poorly I will be sure to be quick to respond with any questions. Thanks!

2 Answers

Update: Took me hours but the problem was I had empty spaces in my brownie-config.yaml

A 3 hour bug for a 5 second fix :)

dependencies:
  # - <organization/repo>@<version>
  - smartcontractkit/chainlink-brownie-contracts@0.2.1
compiler:
  solc:
    remappings:
      - "@chainlink=smartcontractkit/chainlink-brownie-contracts@0.2.1"
dotenv: .env
networks:
  rinkeby:
    eth_usd_price_feed: "0x035dCD3b056BdDbf82273A1b93c7B8cd25614995"
  kovan:
  mainnet:
wallets:
  from_key: ${PRIVATE_KEY}

I just needed to remove the kovan and mainnet and then it started working!

Related