python / python/typeshed

TypeDict and `Mapping[Any, object]` incompatibilities for `unittest.assertDictEqual`

Open
#11,153 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

I've just added types to the common dictionary used throughout my codebase. But now my assertDictEqual gives a type error:

Expected type 'Mapping[Any, object]', got 'MyDictTypeName' instead

What's the trick here? - Should I narrow the types with a Union?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names unittest.assertDictEqual but does not identify a file or test. Start by locating its typeshed stub and reproducing the reported incompatibility with a typed dictionary; done means the supported call no longer produces the reported type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.