So I have this method which creates an instance of a class.
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
And this is the class:
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)
So the code works just fine, but PyCharm gives me this warning that:
Type "Item" doesn't have expected attributes
What can I do to resolve/suppress this warning?