artomason
artomason

Reputation: 3993

Unresolved Attribute Reference

I'm using the new version of PyCharm to work with Python. I'm receiving a

Unresolved attribute reference 'ItemLocation' for class 'Item'

but the application launches fine with no errors or crashes, any ideas?

class Item:
    def __init__(self, state = '', location = '', realm = 'All', index =- 1):
        self.__dict__ = {
            'ActiveState': state,
            'ItemEquipped': 0,
            'ItemLocation': location,  # <-- DEFINED HERE
            'ItemRealm': realm,
            'ItemLevel': '51',
            'ItemQuality': '100',
            'ItemType': '',
            'ItemName': '',
            'ItemAFDPS': '',
            'ItemSpeed': '',
            'ItemBonus': '',
            'ItemSource': '',
            'LeftHand': '',
            'ItemDamageType': '',
            'ItemRestrictions': list(),
            'ItemNotes': '',
            'ItemRequirement': '',
            'TemplateIndex': index,
        }

        self.ItemSlotList = list()

        if self.ItemLocation in SlotList['Jewelery']:  # <-- HERE
            self.ActiveState = 'drop'
            self.ItemEquipped = 2
        elif self.ItemLocation in SlotList['Armor']:  # <-- HERE
            self.ActiveState = 'crafted'
            self.ItemEquipped = 2
        elif self.ItemLocation in SlotList['Weapons']:  # <-- HERE
            self.ActiveState = 'drop'
            self.ItemEquipped = 0
        elif self.ItemLocation in SlotList['Mythical']:  # <-- HERE
            self.ActiveState = 'drop'
            self.ItemEquipped = 2

        # TODO: DETERMINE 'ItemEquipped' FOR WEAPONS BASED ON CLASS SELECTION

        self.ItemSlotList = self.makeItemSlots()

Sorry if things look noobish, I'm still learning. I'm running Python 3 and PyQt5

Upvotes: 0

Views: 1540

Answers (1)

internet_user
internet_user

Reputation: 3279

I don't use PyCharm but I assume that it doesn't check __dict__ assignments, because they allow for dynamic assignment, so it would basically have to run the code to check it.

Upvotes: 1

Related Questions