Skip to content
← All Python tracks

Interfaces with Protocols and ABCs

Python

Describe what a function needs from its arguments with protocols and abstract base classes. Then give precise types to dictionaries, overloads and decorators, and find where Any and missing stubs leave code unchecked.

This track uses Python. You can make it your practice mode to browse related content across the site.

20 exercises

6 articles

Explore freely. Sign in to keep your progress.

Your learning sequence

  1. 1 Accept Any Object That Has the Right Methods Read
  2. 2 Not solved yet. Write a Protocol for Three Unrelated Classes Practice · Easy
  3. 3 Choose Between a Protocol and an ABC Read
  4. 4 Not solved yet. Build an ABC with an Abstract Property and Classmethod Practice · Easy
  5. 5 Not solved yet. Catch the Backends That isinstance Lets Through Practice · Medium
  6. 6 Not solved yet. Inherit a Default Method from a Protocol Practice · Medium
  7. 7 Not solved yet. Type a Handler Registry with a Callback Protocol Practice · Medium
  8. 8 Not solved yet. Fix the Variance of a Serializer and a Parser Practice · Hard
  9. 9 Not solved yet. Make a Protocol Member Read-Only with a Property Practice · Hard
  10. 10 Not solved yet. Describe a Dictionary's Keys with TypedDict Practice · Easy
  11. 11 Not solved yet. Accept Three Event Types with a Read-Only TypedDict Practice · Medium
  12. 12 Not solved yet. Type **kwargs with a TypedDict and Unpack Practice · Medium
  13. 13 Not solved yet. Type a Lookup with a Default Using Overloads Practice · Hard
  14. 14 Not solved yet. Write Decorators That Keep the Signature with ParamSpec Practice · Hard
  15. 15 Not solved yet. Check Number Ranges at Runtime with Annotated Practice · Medium
  16. 16 Not solved yet. Restrict One Method to String Builders with Self Types Practice · Medium
  17. 17 Not solved yet. Find Where Any Leaks into Function Signatures Practice · Medium
  18. 18 Not solved yet. Validate Records with TypeIs Instead of cast Practice · Medium
  19. 19 Not solved yet. Clean Up type: ignore Comments Practice · Easy
  20. 20 Not solved yet. Work Out What __all__ and Re-exports Make Public Practice · Medium
  21. 21 Ship Your Library's Type Hints with py.typed Read
  22. 22 Not solved yet. Write a Minimal Stub for an Untyped Package Practice · Hard
  23. 23 Not solved yet. Keep the Type at Each Tuple Position with TypeVarTuple Practice · Hard
  24. 24 Control the Extra Keys of a TypedDict Read
  25. 25 Accept Types Like str | None as Arguments with TypeForm Read
  26. 26 Why Some Classes Cannot Share a Subclass Read

Check yourself

5 questions · not saved while you're signed out

Use these questions to check your understanding and compare explanations. Your score does not affect track completion.

0 / 5 correct

What does NotRequired[str] allow for the email key?

Choose one answer to reveal the explanations. Answers are kept only while this page is open.

from typing import NotRequired, TypedDict


class User(TypedDict):
    name: str
    email: NotRequired[str]


ada: User = {"name": "Ada"}
Question 1 of 5