До добавления функции 'filter_bad_items' все работало изумительно
class ItemService:
def enrich_with_data(self, session: requests.Session, items: list[Item]) -> list[Item]:
for item in items:
response = self.repository.get_additional_data(session, item)
item_info = response.json()['iteminfo']
item.full_item_name = item_info['full_item_name']
#print(item.full_item_name)
return items, item.full_item_name
def filter_bad_items(self,full_item_name, items: list[Item]) -> list[Item]:
print(full_item_name + '1234123')
if full_item_name in ['XM1014 | Seasons (Factory New)']:
return [item for item in items if (item.floatvalue in config.GOOD_FLOAT_VALUES2)]
elif full_item_name in ['Glock-18 | High Beam (Factory New)']:
return [item for item in items if (item.floatvalue in config.GOOD_FLOAT_VALUES1)]
items, full_item_name = item_service.enrich_with_data(session, items)
print(full_item_name)
items = item_service.filter_bad_items(full_item_name,items)
Код ошибки:
!! File "C:\Users\User\Desktop\PATERN\app\main.py", line 42, in perform_item_instances_check
items, full_item_name = item_service.enrich_with_data(session, items)
!! File "C:\Users\User\Desktop\PATERN\app\services.py", line 85, in enrich_with_data
return items, item.full_item_name
!! UnboundLocalError: local variable 'item' referenced before assignment