'Python 'dict' object has no attribute

I defined some classes, I will provide class where I have issue:

class ImdbData:
    def __init__(self, generalResponse: ImdbGeneralResponse, tvResponse: Iterable[ImdbTvDataResponse]):
        self._generalResponse = generalResponse;
        self._tvResponse = tvResponse;
        
    @property
    def generalResponse(self):
        return self._generalResponse
    
    @property
    def tvResponse(self):
        return self._tvResponse

I created a service:

class ImdbService:
    @staticmethod
    def read(url:str, seasonNum:int = 0) -> model.imdbresponse.ImdbData:
        imdbCodeMatch = re.search("tt(\d+)", url)
        imdbCode = imdbCodeMatch.group()
        season = ""
        
        if (seasonNum > 0):
            season = str(seasonNum);
        
        requestUrl:str = f'https://mytool/{imdbCode}/{season}'
        response = requests.get(requestUrl)
        return json.loads(response.content)

and finally I call like:

sv = services.imdbsv.ImdbService.read("https://www.imdb.com/title/tt9741310/")
print(sv.generalResponse.description)

But I got error:

'dict' object has no attribute 'generalResponse'

Why ? in VS Code, when I press on F12 over generalResponse, the IDE redirects me to that property decorator which is good.

Still cannot figure why I got error



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source