一个很怪的keyerror

问题遇到的现象和发生背景

在后面调用这个类时出现了keyerror错误,但是类单独运行时是不报错的

问题相关代码,请勿粘贴截图class derivatives_portfolio(object):
def __init__(self, name, positions, val_env, assets, 
             correlations=None, fixed_seed=False): 
    self.name = name 
    self.positions = positions 
    self.val_env = val_env 
    self.assets = assets 
    self.underlyings = set() 
    self.correlations = correlations 
    self.time_grid = None 
    self.underlying_objects = {} 
    self.valuation_objects = {} 
    self.fixed_seed = fixed_seed 
    self.special_dates = []
    
    for pos in self.positions:
        self.val_env.constants['starting_date'] =\
            min(self.val_env.constants['starting_date'], 
                positions[pos].mar_env.pricing_date) 
        self.val_env.constants['final_date'] = \
            max(self.val_env.constants['final_date'], 
                positions[pos].mar_env.constants['maturity'])
        self.underlyings.add(positions[pos].underlying)
    start = self.val_env.constants['starting_date'] 
    end = self.val_env.constants['final_date'] 
    time_grid = pd.date_range(start=start, end=end, 
                              freq=self.val_env.constants['frequency'] 
                              ).to_pydatetime()
    time_grid = list(time_grid) 
运行结果及报错内容
positions[pos].mar_env.constants['maturity'])

KeyError: 'maturity'

我的解答思路和尝试过的方法
我想要达到的结果

运行成功

检查一下拼写错误