PyCQA / PyCQA/flake8-pyi

Encourage typing_extensions.Unpack for many overload-invariant keywords

Open
#285 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

deferred
Dominant language
Python
Stars
83
Forks
22
PR merge metrics
No merged PRs in 30d

Description

If a function has many keyword arguments that do not change across all overloads (for example pandas.read_csv). It is more readable and shorter to move all the overload-invariant keywords into a TypedDict and suggest using the Unpack feature which is supported by at least pyright and mypy.

This would probably need some heuristic of when is it worth recommending Unpack: Using a TypedDict for less than insert magic number keywords is probably not helpful.

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 reviewing the pandas.read_csv stub example linked in the issue and the project's existing rule implementations and tests. Determine how a rule could identify overload-invariant keyword arguments and what threshold should trigger an Unpack recommendation. Done means the behavior and heuristic are specified, implemented, and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.