Synfig Issue Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
OPEN  Bug report #9190  -  TypeError
Posted Today (07:51) - updated Today (07:51)
action_vote_minus_faded.png
0
Votes
action_vote_plus_faded.png
Issue details
  • Type of issue
    Bug report
  • Status
     
    New
  • Assigned to
    Not assigned to anyone
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     Uniorrr
  • Owned by
    Not owned by anyone
  • Category
    Not determined
  • Resolution
    Not determined
  • Priority
    Not determined
  • Targetted for
    icon_milestones.png Not determined
  • Tags
    icon_customdatatype.png Not determined
  • Difficulty
    icon_customdatatype.png Not determined
Issue description
Please help me debug the code. I was debugging a production issue that came out of nowhere. The logs pointed to a Type Error in code that had been stable for months. It wasn’t clear why it was happening—sometimes the code ran fine, and other times it crashed. I spent hours trying to isolate the problem but couldn’t figure it out. Frustrated, I created a simplified version of the code to show my team and ask for help. Here’s the problem: The Coding Challenge: The Shifting Shadow Problem You have a list of user profiles, each represented as a dictionary with name, age, and active. Your task is to: Normalize the profiles (e.g., capitalize names, set missing ages to 0). Sort them alphabetically by name. Return a dictionary containing: active_users: a list of names of active users. average_age: the average age of all users (rounded to 2 decimal places). inactive_users: a list of names of inactive users. The issue? Occasionally, this code throws a Type Error: unsupported operand type(s) for +: 'int' and 'None Type'. Here's the code: python Copy code from typing import List, Dict, Union def process_user_profiles(profiles: List Union[str, int, bool]]) -> Dict Union[List[str, float]]: # Normalize profiles normalized = { "name": p.get("name", "").strip().title(), "age": int(p.get("age", 0)), # Assume missing ages are 0 "active": bool(p.get("active", False)) } for p in profiles # Sort alphabetically by name normalized.sort(key=lambda x: x"name") # Separate active and inactive users active_users = p["name" for p in normalized if p"active"] inactive_users = p["name" for p in normalized if not p"active"] # Calculate average age total_age = sum(p"age" for p in normalized) average_age = total_age / len(normalized) return { "active_users": active_users, "average_age": round(average_age, 2), "inactive_users": inactive_users } # Example usage profiles = [ {"name": "alice", "age": 25, "active": True}, {"name": "Bob", "age": 30, "active": False}, {"name": "Charlie", "age": None, "active": True}, {""
 	
Steps to reproduce this issue
Bug report

#1
Comment posted by
 cotomoto
Today, 12:39
Gosh, your code looks like a real mess! No wonder you have Type Error here. I couldn't even read it properly. Look, you must write the code according to the rules, meaning that what is supposed to start from a new line, should be moved to its proper place. If you have no skills or time to make your program work well, you can look for the info about the side of software development outsourcing and hire external programmers to help you.