Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14271

Flask: TypeError: '

$
0
0

In my Flask backend, I receive a dict that gets processed and added to different dicts.

    def updateIncomeExpenses(self, incomingUpdate):'''        The list of dicts are iterated over, and dicts are added to their respective lists.            Parameter:            incomingUpdate (list): A list of dictionaries with entries that are either incomes or expenses'''        self.__latestUpdate = incomingUpdate        for item in self.__latestUpdate:            item = {key:val for key,val in item.items() if val != None}            if item.get("incomes"):                item["incomes"] = float(item.get("incomes"))                self.__incomes[item.get("id")] = item                self.__incomes["summary"] += item.get("incomes")            elif item.get("expenses"):                item["expenses"] = float(item.get("expenses"))                self.__expenses[item.get("id")] = item                self.__expenses["summary"] += item.get("expenses")            elif item.get("savings"):                item["savings"] = float(item.get("savings"))                self.__savings[item.get("id")] = item                self.__savings["summary"] += item.get("savings")            elif item.get("investments"):                item["investments"] = float(item.get("investments"))                self.__investments[item.get("id")] = item                self.__investments["summary"] += item.get("investments")

Even as I don't do any comparisons, the following error is thrown, and the traceback is not helping me find it.

Error: TypeError: '<' not supported between instances of 'int' and 'str'

Traceback:

Traceback (most recent call last):  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2463, in __call__    return self.wsgi_app(environ, start_response)  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2449, in wsgi_app    response = self.handle_exception(e)  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1866, in handle_exception    reraise(exc_type, exc_value, tb)  File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise    raise value  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app    response = self.full_dispatch_request()  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request    return self.finalize_request(rv)  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1969, in finalize_request    response = self.process_response(response)  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2268, in process_response    self.session_interface.save_session(self, ctx.session, response)  File "/usr/local/lib/python3.8/site-packages/flask/sessions.py", line 378, in save_session    val = self.get_signing_serializer(app).dumps(dict(session))  File "/usr/local/lib/python3.8/site-packages/itsdangerous/serializer.py", line 207, in dumps    payload = want_bytes(self.dump_payload(obj))  File "/usr/local/lib/python3.8/site-packages/itsdangerous/url_safe.py", line 53, in dump_payload    json = super().dump_payload(obj)  File "/usr/local/lib/python3.8/site-packages/itsdangerous/serializer.py", line 169, in dump_payload    return want_bytes(self.serializer.dumps(obj, **self.serializer_kwargs))  File "/usr/local/lib/python3.8/site-packages/flask/json/tag.py", line 305, in dumps    return dumps(self.tag(value), separators=(",", ":"))  File "/usr/local/lib/python3.8/site-packages/flask/json/__init__.py", line 211, in dumps    rv = _json.dumps(obj, **kwargs)  File "/usr/local/lib/python3.8/json/__init__.py", line 234, in dumps    return cls(  File "/usr/local/lib/python3.8/json/encoder.py", line 199, in encode    chunks = self.iterencode(o, _one_shot=True)  File "/usr/local/lib/python3.8/json/encoder.py", line 257, in iterencode    return _iterencode(o, 0)TypeError: '<' not supported between instances of 'int' and 'str'

This has me so confused, and would love if anyone has an idea as to what this might be.


Viewing all articles
Browse latest Browse all 14271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>