简体   繁体   English

未解析的属性参考

[英]Unresolved Attribute Reference

I'm using the new version of PyCharm to work with Python. 我正在使用新版本的PyCharm与Python一起使用。 I'm receiving a 我收到一个

Unresolved attribute reference 'ItemLocation' for class 'Item' 类“ Item”的未解析属性引用“ ItemLocation”

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 我正在运行Python 3和PyQt5

我不使用PyCharm,但我假设它不检查__dict__分配,因为它们允许动态分配,因此基本上必须运行代码来检查它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM