python-attrs / python-attrs/cattrs

pyright says that type of cattrs.preconf.json.make_converter is partially unknown

Open
#593 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.1k
Forks
159
Avg merge
12h 21m
Merged PRs (30d)
6

Description

Pyright flags the code below with "Type of "make_converter" is partially unknown".

converter = cattrs.preconf.json.make_converter()

The problem is the type of the parameter unstruct_collection_overrides: Mapping[type, (...) -> Unknown].

Poking around in the cattrs code, this error can be resolved by changing the type of unstruct_collection_overrides in Converter.Init from

unstruct_collection_overrides: Mapping[type, Callable] = {}

to
unstruct_collection_overrides: Mapping[type, UnstructureHookT] = {}

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

Start by inspecting Converter.Init and the unstruct_collection_overrides annotation, then trace how cattrs.preconf.json.make_converter() uses it. Compare the annotation with UnstructureHookT and verify that the reported partially unknown type is resolved without changing the converter's behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.