Bird
0
0

What is wrong with this state schema?

medium📝 Debug Q7 of 15
LangChain - LangGraph for Stateful Agents
What is wrong with this state schema?
class ProfileState:
    age: int
    hobbies: list
AThe age field must be a string, not int.
BClass must inherit from a base schema class.
CThe type hint for hobbies should specify the list item type, e.g., list[str].
DThere should be no type hints in state schemas.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the type hint for hobbies

    Using just list is allowed but incomplete; specifying item type like list[str] improves clarity and validation.
  2. Step 2: Check other options

    Age as int is correct, inheritance is optional, and type hints are required for clarity.
  3. Final Answer:

    The type hint for hobbies should specify the list item type, e.g., list[str]. -> Option C
  4. Quick Check:

    Specify item types in collections for clarity [OK]
Quick Trick: Always specify item types in list type hints [OK]
Common Mistakes:
MISTAKES
  • Leaving list type hints generic
  • Changing correct int types unnecessarily
  • Thinking inheritance is mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes