Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x “如何压制”;类型不为';“没有预期的属性”;_Python 3.x_Pycharm - Fatal编程技术网

Python 3.x “如何压制”;类型不为';“没有预期的属性”;

Python 3.x “如何压制”;类型不为';“没有预期的属性”;,python-3.x,pycharm,Python 3.x,Pycharm,我有一个方法,它创建了一个类的实例 def process_item(self, json_item, msg_type): """ Creates an item instance with the 'json_item' from the redis queue. Then the instance is used to create and send the alarm and ping request.

我有一个方法,它创建了一个类的实例

    def process_item(self, json_item, msg_type):
        """
        Creates an item instance with the 'json_item' from the redis queue.
        Then the instance is used to create and send the alarm and ping request.
        At the end, the instance is deleted.
        :param msg_type: Type of message (Alarm or ping)
        :param json_item: The item from the redis queue in json format
        :return: None
        """
        item = Item(json_item)  # Creates an item instance with the json data.
        if msg_type == 'alarm':
            self.create_alarm_request(item)  # Here appears the warning
        elif msg_type == 'ping':
            self.create_ping_request(item)  # Here appears the warning
        else:
            self.logger.error("Unexpected error")
        del item

这是一节课:
import json


class Item(object):

    def __init__(self, item):
        """
        Generates the object attributes from the json item in the arguments.
        The key is used as attribute name and value as attribute value
        :param item: Item in json format from redis queue
        """
        self.__dict__ = json.loads(item)

所以代码运行得很好,但是PyCharm给了我一个警告: 类型“Item”没有预期的属性


如何解决/抑制此警告?